From 132d3236bb884433bf94e961f6d32264e0334aec Mon Sep 17 00:00:00 2001 From: ornitorrincos Date: Tue, 18 Aug 2026 12:15:05 +0200 Subject: --- kernel/loader.s | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 kernel/loader.s (limited to 'kernel/loader.s') 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 -- cgit v1.2.3-70-g09d2