diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-29 12:53:57 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-29 12:53:57 -0400 |
| commit | c2788174198632e0c8bdbfa7762081f595460bdf (patch) | |
| tree | 373b1f5c7cfe0e87f29c1c8956579c58b4f22bf9 /arch/x86_64/proc/process.c | |
| parent | 8de23ca36173cfdb3c609074496115ebd9045887 (diff) | |
| download | jove-kernel-c2788174198632e0c8bdbfa7762081f595460bdf.tar.gz jove-kernel-c2788174198632e0c8bdbfa7762081f595460bdf.tar.bz2 jove-kernel-c2788174198632e0c8bdbfa7762081f595460bdf.zip | |
move process code into proc. add panic folder
Diffstat (limited to 'arch/x86_64/proc/process.c')
| -rw-r--r-- | arch/x86_64/proc/process.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/arch/x86_64/proc/process.c b/arch/x86_64/proc/process.c new file mode 100644 index 0000000..55af85a --- /dev/null +++ b/arch/x86_64/proc/process.c @@ -0,0 +1,64 @@ +#include "process.h" +#include "proc/process.h" +#include "arch/x86_64/hal/obj.h" +#include "arch/x86_64/hal/smp.h" +#include "arch/x86_64/hal/paging.h" +#include "hal/obj.h" +#include "hal/smp.h" +#include "lib/string.h" +#include "init.h" +#include "jove.h" + +PAGEALIGN uint8_t s_init_iopb[0x2000]; +PAGEALIGN char _init_pcb_bytes[0x1000] = { 0 }; +pcb_t *_init_pcb = (pcb_t*)&_init_pcb_bytes; + +pid_t +pcb_pid(pcb_t *pcb) +{ + return pcb->pid; +} + +jove_obj_t* +pcb_rootdir(pcb_t *pcb) +{ + return pcb->rootdir; +} + +void +processing_setup(void (*process_main)) +{ + memset(s_init_iopb, 0xFF, 0x2000); + uintptr_t ksp = ((uintptr_t)&_init_pcb_bytes) + 0xFF8; + + _init_pcb->tree_node.get_key = (void*)pcb_pid; + + _init_pcb->pid = 1; + _init_pcb->ksp = (void*)ksp; + _init_pcb->pml4 = paging_get_pml4(); + _init_pcb->rootdir = _rootdir_obj; + + jove_owned_obj_t *iopb_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_IOPB_I); + obj_settype(iopb_obj, JOVE_OBJ_IOPB); + obj_setvalue(iopb_obj, (uintptr_t)s_init_iopb); + _init_pcb->iopb = iopb_obj; + + processor_t *proc = processor_current(); + proc->tss.rsp[0] = (uintptr_t)_init_pcb->ksp; + memcpy(proc->iopb, s_init_iopb, 0x2000); + + { + jove_owned_obj_t *process_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_PCB_I); + obj_settype(process_obj, JOVE_OBJ_PCB); + obj_setvalue(process_obj, (uintptr_t)_init_pcb); + + proc->pcb_obj = process_obj; + proc->pcb = _init_pcb; + } + + __asm__ volatile("\ + movq %0, %%rsp; \ + xorq %%rbp, %%rbp; \ + jmpq %1":: + "r"(_init_pcb->ksp), "r"(process_main)); +} |
