summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/entry.c18
-rw-r--r--kernel/kernel.h27
-rw-r--r--kernel/kernel.ld5
-rw-r--r--kernel/multiboot.h2
4 files changed, 34 insertions, 18 deletions
diff --git a/kernel/entry.c b/kernel/entry.c
index 1596429..6058910 100644
--- a/kernel/entry.c
+++ b/kernel/entry.c
@@ -1,18 +1,4 @@
-#include "types.h"
-#include "multiboot.h"
-
-extern void addr_phys;
-extern void addr_virt;
-extern void addr_virt_end;
-extern void addr_load_virt;
-extern void addr_load_virt_end;
-
-extern void entry_stack;
-extern multiboot_info_t entry_multiboot;
-
-extern uint32_t entry_pagedir[];
-extern uint32_t entry_pagetable_low[];
-extern uint32_t entry_pagetable_high[];
+#include "kernel.h"
extern void main();
@@ -92,7 +78,7 @@ void entry_main(uint32_t mb_magic, multiboot_info_t* mb_info) {
// TODO: Check that segments are loaded and mapped right.
// Call main() in virtual memory.
- asm volatile("mov $0, %esp");
+ asm volatile("mov $stack_top, %esp");
main();
stop:
diff --git a/kernel/kernel.h b/kernel/kernel.h
new file mode 100644
index 0000000..6793e7d
--- /dev/null
+++ b/kernel/kernel.h
@@ -0,0 +1,27 @@
+#ifndef KERNEL_H
+#define KERNEL_H
+
+// Symbols defined in kernel.ld.
+
+#include "types.h"
+#include "multiboot.h"
+
+extern void addr_phys;
+extern void addr_virt;
+extern void addr_virt_end;
+extern void addr_load_virt;
+extern void addr_load_virt_end;
+
+extern void entry_stack;
+
+extern multiboot_info_t entry_multiboot;
+extern multiboot_info_t multiboot_info;
+
+extern uint32_t entry_pagedir[];
+extern uint32_t entry_pagetable_low[];
+extern uint32_t entry_pagetable_high[];
+
+extern volatile uint32_t map_p2[1024];
+extern volatile union {uint32_t l[1024]; uint32_t b[1024][1024];} map_p1;
+
+#endif
diff --git a/kernel/kernel.ld b/kernel/kernel.ld
index 28f63c7..e377fbd 100644
--- a/kernel/kernel.ld
+++ b/kernel/kernel.ld
@@ -59,4 +59,9 @@ SECTIONS {
. = ALIGN(0x1000);
multiboot_info = .; . += 0x1000;
+ . = 0x100000000;
+ stack_top = .; . -= 0x400000;
+ map_p2 = .; . -= 0x400000;
+ map_p1 = .;
+
}
diff --git a/kernel/multiboot.h b/kernel/multiboot.h
index ffc3d25..f355bfd 100644
--- a/kernel/multiboot.h
+++ b/kernel/multiboot.h
@@ -47,6 +47,4 @@ typedef struct {
uint32_t vbe_interface_len;
} multiboot_info_t;
-extern multiboot_info_t multiboot_info;
-
#endif