1 ; AcessOS Microkernel Version
\r
6 KERNEL_BASE equ 0xC0000000
\r
11 [section .multiboot]
\r
13 ; Multiboot macros to make a few lines later more readable
\r
14 MULTIBOOT_PAGE_ALIGN equ 1<<0
\r
15 MULTIBOOT_MEMORY_INFO equ 1<<1
\r
16 MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
\r
17 MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
\r
18 MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
\r
20 ; This is the GRUB Multiboot header. A boot signature
\r
21 dd MULTIBOOT_HEADER_MAGIC
\r
22 dd MULTIBOOT_HEADER_FLAGS
\r
23 dd MULTIBOOT_CHECKSUM
\r
24 dd mboot - KERNEL_BASE ;Location of Multiboot Header
\r
26 ; Multiboot 2 Header
\r
28 MULTIBOOT2_HEADER_MAGIC equ 0xE85250D6
\r
29 MULTIBOOT2_HEADER_ARCH equ 0
\r
30 MULTIBOOT2_HEADER_LENGTH equ (mboot2_end-mboot2)
\r
31 MULTIBOOT2_CHECKSUM equ -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_HEADER_ARCH + MULTIBOOT2_HEADER_LENGTH)
\r
33 dd MULTIBOOT2_HEADER_MAGIC
\r
34 dd MULTIBOOT2_HEADER_ARCH
\r
35 dd MULTIBOOT2_HEADER_LENGTH
\r
36 dd MULTIBOOT2_CHECKSUM
\r
37 ; MBoot2 Address Header
\r
40 dd mboot2 ; Location of Multiboot Header
\r
41 dd __load_addr - KERNEL_BASE ; Kernel Load base
\r
42 dd __bss_start - KERNEL_BASE ; Kernel Data End
\r
43 dd gKernelEnd - KERNEL_BASE ; Kernel BSS End
\r
44 ; MBoot2 Entry Point Tag
\r
47 dd start - KERNEL_BASE
\r
48 ; MBoot2 Module Alignment Tag
\r
51 dd 0 ; Search me, seems it wants padding
\r
62 mov esp, Kernel_Stack_Top
\r
65 mov ecx, gaInitPageDir - KERNEL_BASE
\r
69 or ecx, 0x80010000 ; PG and WP
\r
72 lea ecx, [.higherHalf]
\r
77 push ebx ; Multiboot Info
\r
78 push eax ; Multiboot Magic Value
\r
88 ; Multiprocessing AP Startup Code (Must be within 0x10FFF0)
\r
94 [extern gpMP_LocalAPIC]
\r
95 [extern gaAPIC_to_CPU]
\r
97 [extern giNumInitingCPUs]
\r
98 lGDTPtr: ; Local GDT Pointer
\r
100 dd gGDT-KERNEL_BASE
\r
105 xchg bx, bx ; MAGIC BREAK!
\r
108 lgdt [DWORD ds:lGDTPtr-KERNEL_BASE-0xFFFF0]
\r
112 jmp 08h:DWORD .ProtectedMode-KERNEL_BASE
\r
116 mov eax, gaInitPageDir - KERNEL_BASE
\r
119 or eax, 0x80010000 ; PG and WP
\r
121 ; Jump to higher half
\r
122 lea eax, [.higherHalf]
\r
125 ; Load True GDT & IDT
\r
129 mov eax, [gpMP_LocalAPIC]
\r
132 mov cl, BYTE [eax+0x10]
\r
133 ; CL is now local APIC ID
\r
134 mov cl, BYTE [gaAPIC_to_CPU+ecx]
\r
135 ; CL is now the CPU ID
\r
136 mov BYTE [gaCPUs+ecx*8+1], 1
\r
137 ; Decrement the remaining CPU count
\r
138 dec DWORD [giNumInitingCPUs]
\r
139 ; CPU is now marked as initialised
\r
151 ; int CallWithArgArray(void *Ptr, int NArgs, Uint *Args)
\r
152 ; Call a function passing the array as arguments
\r
153 [global CallWithArgArray]
\r
157 mov ecx, [ebp+12] ; Get NArgs
\r
161 mov eax, [edx+ecx*4-4]
\r
172 [global gaInitPageDir]
\r
173 [global gaInitPageTable]
\r
176 dd gaInitPageTable-KERNEL_BASE+3 ; 0x00
\r
177 times 1024-256-1 dd 0
\r
178 dd gaInitPageTable-KERNEL_BASE+3 ; 0xC0
\r
187 [global Kernel_Stack_Top]
\r