summaryrefslogtreecommitdiff
path: root/Source/Kernel/Core/loader.wtf.asm
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-08-21 21:16:48 +0200
committerAlexis211 <alexis211@gmail.com>2009-08-21 21:16:48 +0200
commitae803baa4e0ec584c7afd3f6d55f2e6b32010b46 (patch)
treea8d39cdeff28d2ce08ff7485736fef8119669547 /Source/Kernel/Core/loader.wtf.asm
parentf93a269f41659d9a33ea6f24411ca691978986cf (diff)
downloadMelon-ae803baa4e0ec584c7afd3f6d55f2e6b32010b46.tar.gz
Melon-ae803baa4e0ec584c7afd3f6d55f2e6b32010b46.zip
System boots up and shows a nice ASCII art logo.
Diffstat (limited to 'Source/Kernel/Core/loader.wtf.asm')
-rw-r--r--Source/Kernel/Core/loader.wtf.asm59
1 files changed, 59 insertions, 0 deletions
diff --git a/Source/Kernel/Core/loader.wtf.asm b/Source/Kernel/Core/loader.wtf.asm
new file mode 100644
index 0000000..e5f5839
--- /dev/null
+++ b/Source/Kernel/Core/loader.wtf.asm
@@ -0,0 +1,59 @@
+global loader ; making entry point visible to linker
+extern kmain ; kmain is defined elsewhere
+
+; setting up the Multiboot header - see GRUB docs for details
+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 required
+
+section .text
+align 4
+MultiBootHeader:
+ dd MAGIC
+ dd FLAGS
+ dd CHECKSUM
+
+; reserve initial kernel stack space
+STACKSIZE equ 0x4000 ; that's 16k.
+
+extern start_ctors, end_ctors, start_dtors, end_dtors
+
+loader:
+ mov esp, stack+STACKSIZE ; set up the stack
+ push eax ; pass Multiboot magic number
+ push ebx ; pass Multiboot info structure
+
+static_ctors_loop:
+ mov ebx, start_ctors
+ jmp .test
+.body:
+ call [ebx]
+ add ebx,4
+.test:
+ cmp ebx, end_ctors
+ jb .body
+
+ call kmain ; call kernel proper
+
+ cli
+
+static_dtors_loop: ; useless, kernel should never return
+ mov ebx, start_dtors
+ jmp .test
+.body:
+ call [ebx]
+ add ebx,4
+.test:
+ cmp ebx, end_dtors
+ jb .body
+
+hang:
+ hlt ; halt machine should kernel return
+ jmp hang
+
+section .bss
+align 32
+stack:
+ resb STACKSIZE ; reserve 16k stack on a quadword boundary