X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fstart.asm;h=f1d1ea7467ab15ad1b8c75101a3bc0b5ee197b82;hb=ca05044548d5c1de87c030d625a305731a6cc665;hp=41351600054e84eb198b94487dd4b781b14570de;hpb=6749674b892a0865abc22f9a6ec9a624ff40a283;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/start.asm b/Kernel/arch/x86/start.asm index 41351600..f1d1ea74 100644 --- a/Kernel/arch/x86/start.asm +++ b/Kernel/arch/x86/start.asm @@ -39,8 +39,6 @@ start: jmp ecx .higherHalf: - mov DWORD [gaInitPageDir], 0 - ; Call the kernel push ebx ; Multiboot Info push eax ; Multiboot Magic Value @@ -52,6 +50,65 @@ start: hlt jmp .hlt +; +; Multiprocessing AP Startup Code (Must be within 0x10FFF0) +; +%if USE_MP +[extern gGDT] +[extern gGDTPtr] +[extern gIDTPtr] +[extern gpMP_LocalAPIC] +[extern gaAPIC_to_CPU] +[extern gaCPUs] +[extern giNumInitingCPUs] +lGDTPtr: ; Local GDT Pointer + dw 2*8-1 + dd gGDT-KERNEL_BASE + +[bits 16] +[global APStartup] +APStartup: + xchg bx, bx ; MAGIC BREAK! + mov ax, 0xFFFF + mov ds, ax + lgdt [DWORD ds:lGDTPtr-KERNEL_BASE-0xFFFF0] + mov eax, cr0 + or al, 1 + mov cr0, eax + jmp 08h:DWORD .ProtectedMode-KERNEL_BASE +[bits 32] +.ProtectedMode: + ; Start Paging + mov eax, gaInitPageDir - KERNEL_BASE + mov cr3, eax + mov eax, cr0 + or eax, 0x80010000 ; PG and WP + mov cr0, eax + ; Jump to higher half + lea eax, [.higherHalf] + jmp eax +.higherHalf: + ; Load True GDT & IDT + lgdt [gGDTPtr] + lidt [gIDTPtr] + + mov eax, [gpMP_LocalAPIC] + mov DWORD [eax], 0 + xor ecx, ecx + mov cl, BYTE [eax+0x10] + ; CL is now local APIC ID + mov cl, BYTE [gaAPIC_to_CPU+ecx] + ; CL is now the CPU ID + mov BYTE [gaCPUs+ecx*8+1], 1 + ; Decrement the remaining CPU count + dec DWORD [giNumInitingCPUs] + ; CPU is now marked as initialised + sti +.hlt: + hlt + jmp .hlt +%endif + [global GetEIP] GetEIP: mov eax, [esp]