diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-10-04 10:49:41 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-10-04 10:49:41 -0400 |
| commit | 8d48bbd9746228b63bafa5f92b621998d7d8f3d3 (patch) | |
| tree | fbaba69059c2e28d5098da4c9be357c38e406626 /arch/x86_64 | |
| parent | 465cba0c00bfc5d89bf10ce353b0adf40bdc098d (diff) | |
| download | jove-kernel-8d48bbd9746228b63bafa5f92b621998d7d8f3d3.tar.gz jove-kernel-8d48bbd9746228b63bafa5f92b621998d7d8f3d3.tar.bz2 jove-kernel-8d48bbd9746228b63bafa5f92b621998d7d8f3d3.zip | |
move init fully to proc. remove init pages prealloc. prepare for scheduling
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/hal/paging.c | 2 | ||||
| -rw-r--r-- | arch/x86_64/hal/serial_com.c | 2 | ||||
| -rw-r--r-- | arch/x86_64/hal/smp.c | 2 | ||||
| -rw-r--r-- | arch/x86_64/lib/printf.c | 2 | ||||
| -rw-r--r-- | arch/x86_64/main.c | 2 | ||||
| -rw-r--r-- | arch/x86_64/proc/init.c | 33 | ||||
| -rw-r--r-- | arch/x86_64/proc/process.c | 4 | ||||
| -rw-r--r-- | arch/x86_64/proc/process.h | 3 |
8 files changed, 20 insertions, 30 deletions
diff --git a/arch/x86_64/hal/paging.c b/arch/x86_64/hal/paging.c index 408b5d5..a0d6ca9 100644 --- a/arch/x86_64/hal/paging.c +++ b/arch/x86_64/hal/paging.c @@ -2,7 +2,7 @@ #include "arch/x86_64/x86_64.h" #include "hal/memory.h" #include "jove.h" -#include "init.h" +#include "proc/init.h" #include "config.h" #include "hal/obj.h" #include "lib/string.h" diff --git a/arch/x86_64/hal/serial_com.c b/arch/x86_64/hal/serial_com.c index 8454c8a..343d2ae 100644 --- a/arch/x86_64/hal/serial_com.c +++ b/arch/x86_64/hal/serial_com.c @@ -2,7 +2,7 @@ #include "port.h" #include "jove.h" #include "hal/obj.h" -#include "init.h" +#include "proc/init.h" #include "lib/printf.h" static int diff --git a/arch/x86_64/hal/smp.c b/arch/x86_64/hal/smp.c index 4c79d79..b894eb9 100644 --- a/arch/x86_64/hal/smp.c +++ b/arch/x86_64/hal/smp.c @@ -1,5 +1,5 @@ #include "smp.h" -#include "init.h" +#include "proc/init.h" #include "config.h" #include "jove.h" #include "paging.h" diff --git a/arch/x86_64/lib/printf.c b/arch/x86_64/lib/printf.c index f60b943..794a592 100644 --- a/arch/x86_64/lib/printf.c +++ b/arch/x86_64/lib/printf.c @@ -1,7 +1,7 @@ #include "../hal/serial_com.h" #include "lib/printf.h" #include "lib/virtterm.h" -#include "init.h" +#include "proc/init.h" int kvprintf(const char *fmt, va_list ap) diff --git a/arch/x86_64/main.c b/arch/x86_64/main.c index f5a9d39..92f9fe1 100644 --- a/arch/x86_64/main.c +++ b/arch/x86_64/main.c @@ -1,6 +1,6 @@ #include "api/init.h" #include "jove.h" -#include "init.h" +#include "proc/init.h" #include "lib/string.h" #include "lib/printf.h" #include "lib/virtterm.h" diff --git a/arch/x86_64/proc/init.c b/arch/x86_64/proc/init.c index be1d556..3787c7b 100644 --- a/arch/x86_64/proc/init.c +++ b/arch/x86_64/proc/init.c @@ -1,4 +1,4 @@ -#include "init.h" +#include "proc/init.h" #include "arch/x86_64/hal/msr.h" #include "config.h" #include "proc/process.h" @@ -12,10 +12,6 @@ #include "boot/cmdline.h" #include "boot/initrd.h" -PAGEALIGN static uint8_t s_init_program_pages[INIT_PROGRAM_PAGES_MAX][0x1000]; -PAGEALIGN static uint8_t s_init_stack_pages[INIT_STACK_PAGES + 3][0x1000]; -PAGEALIGN static uint8_t s_init_message_page[0x1000]; - static int elf_is_valid(struct elf_header *ehdr) { @@ -78,7 +74,6 @@ init_setup(void) size_t last_base = 0; //Load the init ELF - size_t last_page = 0; for(size_t i = 0; i < init_ehdr->e_phnum; i++) { struct elf_phdr *phdr = init_data + init_ehdr->e_phoff + i * init_ehdr->e_phentsize; if(phdr->p_type != PT_LOAD) continue; @@ -93,18 +88,15 @@ init_setup(void) for(size_t i = 0; i < pages; i++) { uintptr_t page_virt = page_base + (i << 12); - if(last_page >= INIT_PROGRAM_PAGES_MAX) { - kpanic("Program exceeds size limit! (%i > %i)\n", last_page, INIT_PROGRAM_PAGES_MAX); - } int tblres = 0; + jove_owned_obj_t page_frame; do { - uintptr_t tbl_frame = KPTR_TOPHYS(&s_init_program_pages[last_page++]); - tblres = pagedir_map_table(pml4, tbl_frame, page_virt); - if(tblres == EHASMAP) last_page--; - }while(!tblres); + page_frame = init_pop_alloc(); + tblres = pagedir_map_table(pml4, obj_getvalue(&page_frame), page_virt); + }while(tblres == 0); - pagedir_map_frame(pml4, KPTR_TOPHYS(&s_init_program_pages[last_page++]), page_virt, + pagedir_map_frame(pml4, obj_getvalue(&page_frame), page_virt, PAGE_WRITEABLE | PAGE_USER); } @@ -116,25 +108,24 @@ init_setup(void) size_t stack_base = 0x00007FFFFFFFF000; int stack_mapres = 0; - last_page = 0; for(size_t i = 0; i < INIT_STACK_PAGES; i++) { uintptr_t page_virt = stack_base - (i << 12); int tblres = 0; + jove_owned_obj_t page_frame; do { - uintptr_t tbl_frame = KPTR_TOPHYS(&s_init_stack_pages[last_page++]); - tblres = pagedir_map_table(pml4, tbl_frame, page_virt); - if(tblres == EHASMAP) last_page--; + page_frame = init_pop_alloc(); + tblres = pagedir_map_table(pml4, obj_getvalue(&page_frame), page_virt); }while(!tblres); - pagedir_map_frame(pml4, KPTR_TOPHYS(&s_init_stack_pages[last_page++]), page_virt, + pagedir_map_frame(pml4, obj_getvalue(&page_frame), page_virt, PAGE_WRITEABLE | PAGE_USER | PAGE_XD); } //Map the syscall message. last_base = (last_base + 0xFFF) & ~0xFFF; - uintptr_t message_pptr = KPTR_TOPHYS(s_init_message_page); - pagedir_map_frame(pml4, message_pptr, last_base, + jove_owned_obj_t message_frame = init_pop_alloc(); + pagedir_map_frame(pml4, obj_getvalue(&message_frame), last_base, PAGE_WRITEABLE | PAGE_USER | PAGE_XD); extern struct init_payload _init_payload; diff --git a/arch/x86_64/proc/process.c b/arch/x86_64/proc/process.c index 6165585..d5513bc 100644 --- a/arch/x86_64/proc/process.c +++ b/arch/x86_64/proc/process.c @@ -6,7 +6,7 @@ #include "hal/obj.h" #include "hal/smp.h" #include "lib/string.h" -#include "init.h" +#include "proc/init.h" #include "jove.h" PAGEALIGN uint8_t s_init_iopb[0x2000]; @@ -28,6 +28,8 @@ processing_setup(void (*process_main)) init_pcb->header.pagedir = obj_release(objdir_getlocal(_rootdir_obj, ROOTDIR_PAGEDIR_I)); init_pcb->header.pid = 1; + init_pcb->header.state = PCB_STATE_RUNNING; + init_pcb->ksp = (void*)ksp; jove_owned_obj_t *iopb_obj = objdir_getlocal(_rootdir_obj, ROOTDIR_IOPB_I); diff --git a/arch/x86_64/proc/process.h b/arch/x86_64/proc/process.h index 534c8d5..6a0aa96 100644 --- a/arch/x86_64/proc/process.h +++ b/arch/x86_64/proc/process.h @@ -8,13 +8,10 @@ typedef struct process_control_block { struct pcb_expected_header header; - struct process_control_block *sched_next; jove_obj_t *iopb; - enum pcb_state state; int killed; - struct pcb_mailbox send, recv; struct cpu_context context; void *ksp; |
