blob: 6aa5c1a478cb57b13fd77199378dca7946d05a38 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
bits 32
; Some variables
kernel_virt_base equ 0xC0000000
kernel_page_number equ (kernel_virt_base >> 22)
kernel_stack equ 0x4000
section .data
align 0x1000
boot_page_dir:
dd 0x00000083
times (kernel_page_number - 1) dd 0
dd 0x00000083
times (1024 - kernel_page_number - 1) dd 0
section .text
align 4
multiboot:
header_start:
dd 0xe85250d6
dd 0
dd header_end - header_start
dd 0x100000000 - (0xe85250d6 + 0 + (header_end - header_start))
; Information tag
align 8
dw 1
dw 1
dd 24
dd 2 ; bootloader name
dd 4 ; meminfo
dd 6 ; mmap
dd 13 ; smbios
; Page-align tag
align 8
dw 6
dw 0
dd 8
; Empty tag
align 8
dw 0
dw 0
dd 8
header_end:
global boot
extern kernel_main
boot:
mov ecx, (boot_page_dir - kernel_virt_base)
mov cr3, ecx
mov ecx, cr4
or ecx, 0x00000010
mov cr4, ecx
mov ecx, cr0
or ecx, 0x80000000
mov cr0, ecx
lea ecx, [higher_half]
jmp ecx
higher_half:
mov dword [boot_page_dir], 0
invlpg [0]
mov esp, stack + kernel_stack
push esp
push ebx
push eax
cli
call kernel_main
hlt
section .bss
align 32
stack:
resb kernel_stack
|