diff options
-rw-r--r-- | kernel/entry.c | 30 | ||||
-rw-r--r-- | kernel/main.c | 2 |
2 files changed, 29 insertions, 3 deletions
diff --git a/kernel/entry.c b/kernel/entry.c index 28bdb12..1596429 100644 --- a/kernel/entry.c +++ b/kernel/entry.c @@ -8,7 +8,7 @@ extern void addr_load_virt; extern void addr_load_virt_end; extern void entry_stack; -extern void entry_multiboot; +extern multiboot_info_t entry_multiboot; extern uint32_t entry_pagedir[]; extern uint32_t entry_pagetable_low[]; @@ -110,16 +110,42 @@ void entry_main(uint32_t mb_magic, multiboot_info_t* mb_info) { :: "S" (source), "D" (target), "c" (size / 4) \ : "flags", "memory") +unsigned int strcpy(char* source, char* target) { + unsigned int i = 0; + while(*source) { + *target++ = *source++; + i++; + } + *target = 0; + return i + 1; +} + void entry_copy_multiboot(multiboot_info_t* mb_info) { // Copy multiboot structure. memcpy(mb_info, &entry_multiboot, sizeof(multiboot_info_t)); uint32_t low_p = (uint32_t)&entry_multiboot + sizeof(multiboot_info_t); uint32_t high_p = (uint32_t)&multiboot_info + sizeof(multiboot_info_t); + // Copy module structures. memcpy(mb_info->mods_addr, low_p, mb_info->mods_count * sizeof(multiboot_module_t)); - multiboot_info.mods_addr = (multiboot_module_t*)high_p; + entry_multiboot.mods_addr = (multiboot_module_t*)high_p; + multiboot_module_t* mods_addr = (multiboot_module_t*)low_p; low_p += mb_info->mods_count * sizeof(multiboot_module_t); high_p += mb_info->mods_count * sizeof(multiboot_module_t); + + // Copy strings. + unsigned int s; + s = strcpy(entry_multiboot.cmdline, (char*)low_p); + entry_multiboot.cmdline = (char*)high_p; + low_p += s; + high_p += s; + + for(unsigned int i = 0; i < entry_multiboot.mods_count; i++) { + s = strcpy(mods_addr[i].string, (char*)low_p); + mods_addr[i].string = (char*)high_p; + low_p += s; + high_p += s; + } } #define outb(port, value) asm volatile("out %b0,%w1" : : "a" (value), "d" (port)) diff --git a/kernel/main.c b/kernel/main.c index e8de5d2..b25dcb6 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -21,7 +21,7 @@ void main() { printf("IRQs set.\n"); printf("Multiboot flags: %08x\n", multiboot_info.flags); - for(int i = 0; i < multiboot_info.mods_count; i++) { + for(unsigned int i = 0; i < multiboot_info.mods_count; i++) { printf("Module %u: %08x %08x %s\n", i, multiboot_info.mods_addr[0].mod_start, multiboot_info.mods_addr[0].mod_end, multiboot_info.mods_addr[0].string); } |