summaryrefslogtreecommitdiff
path: root/kernel/entry.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/entry.c')
-rw-r--r--kernel/entry.c30
1 files changed, 28 insertions, 2 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))