wip: uncrampt the stack thing in the irq
This commit is contained in:
@ -22,6 +22,6 @@ struct tcb {
|
|||||||
struct tcb *next;
|
struct tcb *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tcb *create_thread(struct pcb *process, void (*routine)(void));
|
struct tcb *create_thread(struct pcb *process, void (*entry)(void));
|
||||||
void delete_thread(struct tcb *thread);
|
void delete_thread(struct tcb *thread);
|
||||||
void switch_thread(struct tcb *thread_to_switch);
|
void switch_thread(struct tcb *thread_to_switch);
|
||||||
|
|||||||
@ -15,7 +15,7 @@ switch_thread:
|
|||||||
// stack pointer + the 4 regs pushed
|
// stack pointer + the 4 regs pushed
|
||||||
// and + 1 to get the argument (next thread)
|
// and + 1 to get the argument (next thread)
|
||||||
.LABEL1:
|
.LABEL1:
|
||||||
mov esi, [esp+(4+1)*4]
|
mov esi, [esp+4]
|
||||||
mov [current_tcb], esi
|
mov [current_tcb], esi
|
||||||
|
|
||||||
mov eax, [current_tcb]
|
mov eax, [current_tcb]
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
struct tcb *create_thread(struct pcb *process, void (*routine)(void))
|
struct tcb *create_thread(struct pcb *process, void (*entry)(void))
|
||||||
{
|
{
|
||||||
static uint32_t tid = 1;
|
static uint32_t tid = 1;
|
||||||
struct tcb *new_tcb = vmalloc(sizeof(struct tcb));
|
struct tcb *new_tcb = vmalloc(sizeof(struct tcb));
|
||||||
@ -21,8 +21,14 @@ struct tcb *create_thread(struct pcb *process, void (*routine)(void))
|
|||||||
}
|
}
|
||||||
// set esp to "skip" the 4 GPRs and eip later to be used as the context
|
// set esp to "skip" the 4 GPRs and eip later to be used as the context
|
||||||
// of the thread
|
// of the thread
|
||||||
new_tcb->esp = new_tcb->esp0 + STACK_SIZE - 5 * 4;
|
uint32_t *stack =
|
||||||
new_tcb->esp[4] = (uint32_t)routine;
|
(uint32_t *)((uint8_t *)new_tcb->esp0 + STACK_SIZE - 5 * 4);
|
||||||
|
|
||||||
|
// testing out some stuff
|
||||||
|
*(--stack) = 0x202; // EFLAGS
|
||||||
|
*(--stack) = 0x08; // CS = kernel code segment
|
||||||
|
*(--stack) = (uint32_t)entry;
|
||||||
|
new_tcb->esp = stack;
|
||||||
new_tcb->process = process;
|
new_tcb->process = process;
|
||||||
new_tcb->next = NULL;
|
new_tcb->next = NULL;
|
||||||
new_tcb->state = NEW;
|
new_tcb->state = NEW;
|
||||||
|
|||||||
Reference in New Issue
Block a user