aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/boot.asm
blob: 0f967b78a17b91730066f28879e232345fe34d8c (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
; The first section of the ELF will be used to locate the entry point.
section .ezlocation
dd _start

; Set stack
section .bss
align 16
global STACK_BOTTOM
global STACK_TOP

STACK_BOTTOM:
resb 0x4000
STACK_TOP:


section .text

global _start
extern kernel_main
_start:
	mov esp, STACK_TOP
	push ebx
	push eax

	call kernel_main
	cli

hlt_L:
	hlt
	jmp hlt_L

%include "src/kernel/gdt/gdt.asm"

%include "src/kernel/interrupts/idt.asm"

%include "src/kernel/interrupts/isr.asm"

%include "src/kernel/interrupts/irq.asm"

%include "src/kernel/interact.asm"

global switch_to_user
extern test_user
switch_to_user:
    sti
    mov ax, 0x23
    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax

    mov eax, esp
    push 0x23
    push eax
    pushf
    push 0x1B
    push test_user
    iret

section .sizedetect
global ASM_KERNEL_END
ASM_KERNEL_END:
	; Kernel size detection