aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/loader.s
blob: 791c23138358df90811fa71218ffa734cd8a2da1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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