X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fstart.asm;h=4dd760365c3bd8284af47d74614ce39f5300202e;hb=d52a53f035af92941c0cafe5f81888fed16d2462;hp=41351600054e84eb198b94487dd4b781b14570de;hpb=1303ed4cedc2e01316d2d033f3dd0b50b190ef81;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/start.asm b/Kernel/arch/x86/start.asm index 41351600..4dd76036 100644 --- a/Kernel/arch/x86/start.asm +++ b/Kernel/arch/x86/start.asm @@ -52,6 +52,52 @@ start: hlt jmp .hlt +; +; Multiprocessing AP Startup Code (Must be within 0x10FFF0) +; +%if USE_MP +[extern gGDTptr] +[extern gpMP_LocalAPIC] +[extern gaAPIC_to_CPU] +[extern gaCPUs] +[global APStartup] + +[bits 16] +APStartup: + xchg bx, bx ; MAGIC BREAK! + mov ax, 0xFFFF + mov ds, ax + lgdt [DWORD ds:gGDTptr-0xFFFF0] + mov eax, cr0 + or al, 1 + mov cr0, eax + jmp 08h:DWORD .ProtectedMode +[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: + 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 + ; CPU is now marked as initialised +.hlt: + hlt + jmp .hlt +%endif + [global GetEIP] GetEIP: mov eax, [esp]