-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.s
68 lines (55 loc) · 1.05 KB
/
boot.s
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
64
65
66
67
68
MBOOT_PAGE_ALIGN equ 1 << 0
MBOOT_MEM_INFO equ 1 << 1
MBOOT_USE_GFX equ 0
MBOOT_MAGIC equ 0x1badb002
MBOOT_FLAGS equ MBOOT_PAGE_ALIGN | MBOOT_MEM_INFO | MBOOT_USE_GFX
MBOOT_CHECKSUM equ -(MBOOT_MAGIC + MBOOT_FLAGS)
section .multiboot
ALIGN 4
DD MBOOT_MAGIC
DD MBOOT_FLAGS
DD MBOOT_CHECKSUM
DD 0, 0, 0, 0, 0
DD 0
DD 800
DD 600
DD 32
SECTION .bss
ALIGN 16
stack_bottom:
RESB 16384 * 8
stack_top:
section .boot
global _start
_start:
MOV ecx, (initial_page_dir - 0xc0000000)
MOV cr3, ecx
MOV ecx, cr4
OR ecx, 0x10
MOV cr4, ecx
MOV ecx, cr0
OR ecx, 0x80000000
MOV cr0, ecx
JMP higher_half
section .text
higher_half:
MOV esp, stack_top
PUSH ebx
PUSH eax
XOR ebp, ebp
extern kernel_main
CALL kernel_main
halt:
hlt
JMP halt
section .data
align 4096
global initial_page_dir
initial_page_dir:
DD 10000011b
TIMES 768-1 DD 0
DD (0 << 22) | 10000011b
DD (1 << 22) | 10000011b
DD (2 << 22) | 10000011b
DD (3 << 22) | 10000011b
TIMES 256-4 DD 0