aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/loader.s
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--kernel/loader.s32
1 files changed, 32 insertions, 0 deletions
diff --git a/kernel/loader.s b/kernel/loader.s
new file mode 100644
index 0000000..791c231
--- /dev/null
+++ b/kernel/loader.s
@@ -0,0 +1,32 @@
+global loader
+extern kmain
+
+section .text
+align 4
+STACKSIZE equ 0x4000
+
+
+loader:
+ ;setup the stack and call the kernel entry point
+ ; shouldn't really use it this way, but take the loading address and move that to rsp to get a working stack
+ mov rsp, stack+STACKSIZE
+ mov rbp, rsp
+
+ ; enable FPU, SSE
+ mov rax, cr0
+ and ax, 0xFFFB
+ or ax, 0x2
+ mov cr0, rax
+ mov rax, cr4
+ or ax, 3 << 9 ; OSFXSR OSXMMEXCPT
+ mov cr4, rax
+
+ ; pass arguments we receiver, or maybe have to get them first fropm the stack
+ call kmain
+ hlt
+
+
+section .bss
+align 32
+stack:
+ resb STACKSIZE