4 KERNEL_BASE equ 0xFFFF800000000000
8 ; Multiboot macros to make a few lines later more readable
9 MULTIBOOT_PAGE_ALIGN equ 1<<0
10 MULTIBOOT_MEMORY_INFO equ 1<<1
11 MULTIBOOT_AOUT_KLUDGE equ 1<<16
12 MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
13 MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO; | MULTIBOOT_AOUT_KLUDGE
14 MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
16 ; This is the GRUB Multiboot header. A boot signature
17 dd MULTIBOOT_HEADER_MAGIC
18 dd MULTIBOOT_HEADER_FLAGS
24 dd mboot ; Location of Multiboot Header
25 dd __load_addr ; Load address
26 dd __bss_start - KERNEL_BASE ; End of .data
27 dd gKernelEnd - KERNEL_BASE ; End of .bss (and kernel)
28 dd start - KERNEL_BASE ; Entrypoint
35 mov [gMultibootMagic - KERNEL_BASE], eax
36 mov [gMultibootPtr - KERNEL_BASE], ebx
38 ; Check for Long Mode support
41 cmp eax, 0x80000001 ; Compare the A-register with 0x80000001.
54 mov eax, gInitialPML4 - KERNEL_BASE
57 ; Enable long/compatability mode
69 lgdt [gGDTPtr - KERNEL_BASE]
70 jmp 0x08:start64 - KERNEL_BASE
75 mov esi, csNot64BitCapable - KERNEL_BASE
91 dd 0x00000000, 0x00209A00 ; 0x08: 64-bit Code
92 dd 0x00000000, 0x00009200 ; 0x10: 64-bit Data
93 dd 0x00000000, 0x0020FA00 ; 0x18: 64-bit User Code
94 dd 0x00000000, 0x0000F200 ; 0x20: 64-bit User Data
95 dd 0x00000000, 0x0040FA00 ; 0x38: 32-bit User Code
96 dd 0x00000000, 0x0040F200 ; 0x30: 32-bit User Data
97 times MAX_CPUS dd 0, 0, 0, 0 ; 0x38+16*n: TSS 0
102 [global gMultibootPtr]
103 [global gMultibootMagic]
110 [global gInitialPML4]
111 gInitialPML4: ; Covers 256 TiB (Full 48-bit Virtual Address Space)
112 dd gInitialPDP - KERNEL_BASE + 3, 0 ; Identity Map Low 4Mb
114 dd gInitialPDP - KERNEL_BASE + 3, 0 ; Map Low 4Mb to kernel base
116 dd gInitialPML4 - KERNEL_BASE + 3, 0 ; Fractal Mapping
119 gInitialPDP: ; Covers 512 GiB
120 dd gInitialPD - KERNEL_BASE + 3, 0
123 gInitialPD: ; Covers 1 GiB
124 dd gInitialPT1 - KERNEL_BASE + 3, 0
125 dd gInitialPT2 - KERNEL_BASE + 3, 0
128 gInitialPT1: ; Covers 2 MiB
144 db "Not 64-bit Capable",0