diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-04 11:31:40 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-04 11:31:40 -0400 |
| commit | 8251da342161767fe203627223ccd4a7026701c6 (patch) | |
| tree | af2db0f11b0ea8ad35f88663a855bab39a80f679 /arch/x86_64/hal/process.c | |
| download | jove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.gz jove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.bz2 jove-kernel-8251da342161767fe203627223ccd4a7026701c6.zip | |
initial commit. working on tasking
Diffstat (limited to 'arch/x86_64/hal/process.c')
| -rw-r--r-- | arch/x86_64/hal/process.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/arch/x86_64/hal/process.c b/arch/x86_64/hal/process.c new file mode 100644 index 0000000..dd49456 --- /dev/null +++ b/arch/x86_64/hal/process.c @@ -0,0 +1,35 @@ +#include "process.h" +#include "arch/x86_64/hal/obj.h" +#include "hal/obj.h" +#include "init.h" +#include "smp.h" +#include "paging.h" +#include "jove.h" + +PAGEALIGN char s_init_pcb_bytes[0x1000] = { 0 }; +static pcb_t *s_init_pcb = (pcb_t*)&s_init_pcb_bytes; + +void +processing_setup(void (*process_main)) +{ + uintptr_t ksp = (uintptr_t)&s_init_pcb_bytes + 8; + s_init_pcb->ksp = (void*)ksp; + s_init_pcb->pml4 = paging_get_pml4(); + + processor_t *proc = processor_current(); + proc->pcb = s_init_pcb; + proc->tss.rsp[0] = (uintptr_t)s_init_pcb->ksp; + + { + jove_owned_obj_t *process_obj = obj_take(objdir_getlocal(_rootdir_obj, ROOTDIR_PCB_I)); + obj_settype(process_obj, JOVE_OBJ_PROCESS); + obj_setvalue(process_obj, (uintptr_t)s_init_pcb); + obj_release(process_obj); + } + + __asm__ volatile("\ + movq %0, %%rsp; \ + movq $0, %%rbp; \ + jmpq %1":: + "r"(s_init_pcb->ksp), "r"(process_main)); +} |
