diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2025-08-19 15:04:04 -0400 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2025-08-19 15:04:04 -0400 |
commit | 858a52c06a4615bd58a6a906333f2ad707d41c0a (patch) | |
tree | 16870cd4d67da283567a72a74d28c04464da292a /apps/init/main.c | |
parent | 65ba015d6c1f248d36ad01a653bc49637804b15b (diff) | |
download | jove-os-858a52c06a4615bd58a6a906333f2ad707d41c0a.tar.gz jove-os-858a52c06a4615bd58a6a906333f2ad707d41c0a.tar.bz2 jove-os-858a52c06a4615bd58a6a906333f2ad707d41c0a.zip |
usermode pager
Diffstat (limited to 'apps/init/main.c')
-rw-r--r-- | apps/init/main.c | 77 |
1 files changed, 10 insertions, 67 deletions
diff --git a/apps/init/main.c b/apps/init/main.c index c8dabdf..17b825e 100644 --- a/apps/init/main.c +++ b/apps/init/main.c @@ -4,11 +4,12 @@ #include <jove/jove.h> #include <jove/object.h> #include <jove/syscall.h> -#include <jove/arch/x86_64/object-pagemap.h> + +#include "memory.h" /**This program acts as a memory and process server.*/ -#define INIT_HEAP_START_BYTES 4096 +#define INIT_HEAP_START_BYTES 8192 __attribute__((section(".bss.heap"))) uint8_t init_heap[INIT_HEAP_START_BYTES]; size_t init_heap_start = (uintptr_t)init_heap; @@ -28,76 +29,18 @@ init_bumpalloc(size_t bytes) return r; } -KernelObjectTyped _logObject; -KernelObjectDirectory _untypedDirectory; -KernelObjectDirectory _processorDirectory; -KernelObjectPageMapping _pageMapping; -KernelObjectDirectory _initrd; -KernelObjectMessage _messageObject; - -#define POPULATE_ROOTDIR_MEMB(memb, i) \ -{ KernelObjectTyped *typed = JOVE_OBJECT_TYPED(memb); \ - __rootdir.children[i] = typed; \ - typed->parent = JOVE_OBJECT_TYPED(&__rootdir); \ - typed->membi = i; \ - if(_syscall_invoke_objdir_getmemb(&__rootdir, i, &typed->type) != 0) { \ - jove_kprintf("Failed to populate objdir root member %i\n", i); \ - spin_fail(); \ - } \ -} - -static void -s_populate_rootdir(init_data_t *init_data) -{ - __rootdir.typed.parent = NULL; - __rootdir.children[0] = JOVE_OBJECT_TYPED(&__rootdir); - - POPULATE_ROOTDIR_MEMB(&_logObject, init_data->log_object); - POPULATE_ROOTDIR_MEMB(&_untypedDirectory, init_data->untyped_data_dir); - POPULATE_ROOTDIR_MEMB(&_processorDirectory, init_data->processor_dir); - POPULATE_ROOTDIR_MEMB(&_pageMapping, init_data->pm_object); - POPULATE_ROOTDIR_MEMB(&_initrd, init_data->initrd_dir); - POPULATE_ROOTDIR_MEMB(&_messageObject, init_data->message_object); - - //Populate untyped table - for(int i = 1; i < 256; i++) { - KernelObjectUntyped untyped; - untyped.typed.parent = &_untypedDirectory; - untyped.typed.membi = i; - if(_syscall_invoke_objdir_getmemb(&_untypedDirectory, i, &untyped.typed.type) != 0) { - jove_kprintf("Failed to get member %i of untyped directory\n", i); - spin_fail(); - } - if(untyped.typed.type != KO_MEMORY_UNTYPED) continue; - _untypedDirectory.children[i] = init_bumpalloc(sizeof(KernelObjectUntyped)); - memcpy(_untypedDirectory.children[i], &untyped, sizeof(KernelObjectUntyped)); - - _syscall_invoke_untyped_size(&untyped, &untyped.bytes); - _syscall_invoke_untyped_alignment(&untyped, &untyped.alignment); - - jove_kprintf("Untyped %i size %X align %X\n", i, untyped.bytes, untyped.alignment); - } -} +KernelObjectDirectory untypedDirectory; void -main(init_data_t *init_data) +main(void *message_ptr) { libjove_init( - (uintmax_t)init_data->message_object, - (void*)init_data->message_object_address); - jove_kprintf("Hello, Userland!\n"); + INIT_OBJECT_MESSAGE, + message_ptr); + _jove_alloc = init_bumpalloc; - s_populate_rootdir(init_data); + jove_kprintf("Hello, Userland!\n"); + pager_setup(); for(;;); } - -__attribute__((section(".text.start"))) -__attribute__((naked)) -void -_start(void) -{ - __asm__ volatile("\ - popq %%rdi; \ - jmp main"::); -} |