summaryrefslogtreecommitdiffstats
path: root/kernel/entry.asm
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/entry.asm')
-rw-r--r--kernel/entry.asm43
1 files changed, 43 insertions, 0 deletions
diff --git a/kernel/entry.asm b/kernel/entry.asm
new file mode 100644
index 0000000..28e491a
--- /dev/null
+++ b/kernel/entry.asm
@@ -0,0 +1,43 @@
+global _start
+global stack_ptr
+
+extern kernel_main
+
+; declare some constants
+MODULEALIGN equ 1<<0 ; align loaded modules on page boundaries
+MEMINFO equ 1<<1 ; provide memory map
+FLAGS equ MODULEALIGN | MEMINFO ; this is the Multiboot 'flag' field
+MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header
+CHECKSUM equ -(MAGIC + FLAGS) ; checksum of above, to prove we are multiboot
+
+; the bootloader will search for this magic sequence
+; and recognize us as a multiboot kernel
+section .multiboot
+align 4
+MultiBootHeader:
+ dd MAGIC
+ dd FLAGS
+ dd CHECKSUM
+
+section .code
+; setup the stack
+STACKSIZE equ 0x16384
+
+_start:
+ mov esp, stack+STACKSIZE
+ push eax
+ push ebx
+
+ call kernel_main
+
+ cli
+
+hang:
+ hlt
+ jmp hang
+
+section .bss
+align 4
+stack:
+ resb STACKSIZE
+stack_ptr: