diff options
Diffstat (limited to 'boot')
-rw-r--r-- | boot/boot.h | 40 | ||||
-rw-r--r-- | boot/cmdline.c | 27 | ||||
-rw-r--r-- | boot/cmdline.h | 10 | ||||
-rw-r--r-- | boot/limine/limine.c | 2 |
4 files changed, 16 insertions, 63 deletions
diff --git a/boot/boot.h b/boot/boot.h deleted file mode 100644 index cfdfa68..0000000 --- a/boot/boot.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef JOVE_BOOT_H -#define JOVE_BOOT_H 1 - -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> - -struct MemoryMapEntry { - uintptr_t base; - size_t length; - bool usable; -}; - -#define MEMORY_MAP_MAX_ENTRIES 128 -struct MemoryMap { - size_t count; - struct MemoryMapEntry entries[MEMORY_MAP_MAX_ENTRIES]; -}; - -#define BOOT_MODULE_MAX_ENTRIES 4 -struct BootModule { - char *path; - char *cmdline; - size_t size; - uintptr_t addr; -}; - -#define KERNEL_INITIAL_STACK_WIDTH (0x1000 * 4) -extern void *boot_kernel_initial_stack_base; -extern uintptr_t boot_kernel_physical_address; -extern const char *boot_kernel_cmdline; - -extern struct MemoryMap boot_memorymap; - -extern struct BootModule boot_modules[BOOT_MODULE_MAX_ENTRIES]; -extern size_t boot_module_count; - -#define boot_kernel_virtual_base 0xFFFFFFFF80000000ULL - -#endif diff --git a/boot/cmdline.c b/boot/cmdline.c index aa6aa05..5a68466 100644 --- a/boot/cmdline.c +++ b/boot/cmdline.c @@ -1,15 +1,18 @@ -#include "cmdline.h" +#include "commandline.h" +#include "klib/hash.h" +#include "klib/rbtree.h" +#include "string.h" #include "boot.h" -#include "mem/memory.h" -#include "lib/string.h" -#include "io/log.h" +#include "memory.h" +#include "print.h" -static struct HashTable s_cmdline_kernel; +static rbtree_t s_cmdline_kernel; const char* cmdline_get(const char *key) { - const char** value = hashtable_get(&s_cmdline_kernel, key, const char*); + intmax_t hash = string_hash(key); + char** value = rbtree_find(&s_cmdline_kernel, hash); if(value == NULL) return NULL; return *value; } @@ -17,7 +20,7 @@ cmdline_get(const char *key) void cmdline_kernel_setup(void) { - hashtable_news(&s_cmdline_kernel, const char*); + rbtree_new(&s_cmdline_kernel, char*); size_t cmdi = 0; const char *cmdline = boot_kernel_cmdline; @@ -28,23 +31,23 @@ cmdline_kernel_setup(void) size_t keyi = cmdi; while(cmdline[keyi] != '=' && cmdline[keyi] != 0) keyi++; if(cmdline[keyi] == 0 || keyi == 0) { - klogf("kernel cmdline is empty or malformed; skipping.\n"); + kwarnf("kernel cmdline is empty or malformed; skipping.\n"); break; } size_t keylen = keyi - cmdi; - char *key = mem_alloc(keylen); + char *key = kmalloc(keylen); memcpy(key, &cmdline[cmdi], keylen); size_t valuei = keyi + 1; while(cmdline[valuei] != ' ' && cmdline[valuei] != 0) valuei++; size_t valuelen = (valuei - keyi) - 1; - char *value = mem_alloc(valuelen); + char *value = kmalloc(valuelen); if(valuelen != 0) memcpy(value, &cmdline[keyi + 1], valuelen); - klogf("%s = %s\n", key, value); - hashtable_insert(&s_cmdline_kernel, key, &value); + kdbgf("%s = %s\n", key, value); + rbtree_insert(&s_cmdline_kernel, string_hash(key), &value); cmdi = valuei + 1; } } diff --git a/boot/cmdline.h b/boot/cmdline.h deleted file mode 100644 index b1162b7..0000000 --- a/boot/cmdline.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef JOVE_BOOT_CMDLINE_H -#define JOVE_BOOT_CMDLINE_H 1 - -#include "lib/hashtable.h" - -const char *cmdline_get(const char *key); - -void cmdline_kernel_setup(void); - -#endif diff --git a/boot/limine/limine.c b/boot/limine/limine.c index 7cc50d0..14f85f5 100644 --- a/boot/limine/limine.c +++ b/boot/limine/limine.c @@ -1,5 +1,5 @@ #include "limine.h" -#include "boot/boot.h" +#include "boot.h" static char s_kernel_stack[KERNEL_INITIAL_STACK_WIDTH]; |