MP trampoline code
Posted: Mon Oct 26, 2009 4:13 am
Hi all,
I have implemented the MP spec 1.4 and have all my AP's running the trampoline. I put it at physical 0x00000000 and have everything started there.
The AP's enter there in 16bit realmode, and i setup a temp gdt (idmapped) and set AP in pmode.
Now everything should be ready for doing the last bit. That last bit of course need calling a 32bit function that is part of the linked kernel.. Here is my problem.. I cannot link this 16bit code together with the 32bit code.. So i wonder, maby i should solve this totally different.. I just cannot see a nice way to do this yet...
Basically whats needed further is loading the TSS for each AP, then loading the IDT and GDT (shared between all cpus) and then calling the dispatcher to jump to AP idle thread..
Any thoughts?
-
Thomas
I have implemented the MP spec 1.4 and have all my AP's running the trampoline. I put it at physical 0x00000000 and have everything started there.
The AP's enter there in 16bit realmode, and i setup a temp gdt (idmapped) and set AP in pmode.
Now everything should be ready for doing the last bit. That last bit of course need calling a 32bit function that is part of the linked kernel.. Here is my problem.. I cannot link this 16bit code together with the 32bit code.. So i wonder, maby i should solve this totally different.. I just cannot see a nice way to do this yet...
Basically whats needed further is loading the TSS for each AP, then loading the IDT and GDT (shared between all cpus) and then calling the dispatcher to jump to AP idle thread..
Any thoughts?
-
Thomas
Code: Select all
[bits 16]
[global _mp_trampoline]
[global _mp_trampoline_end]
_mp_trampoline:
cli
jmp mpstart
mpgdtr: ; 0x00000004
dw mpgdt_end-mpgdt-1 ; Size
dd 0x0000000a ; Where GDT is located..
mpgdt:
; Null
dd 0x00
dd 0x00
; Code
dw 0xffff
dw 0x0000
db 0x00
db 0x9a
db 0xcf
db 0x00
; Data
dw 0xffff
dw 0x0000
db 0x00
db 0x92
db 0xcf
db 0x00
mpgdt_end:
mpstart:
lgdt [0x00000004] ; load gdtr
mov eax,cr0 ; Switch to pmode
or al,1
mov cr0,eax
jmp 0x08:0x00000034 ; Flush GDT by jumping far jmp
[bits 32]
mov eax,0x10
mov ds,eax
mov es,eax
mov fs,eax
mov gs,eax
mov ss,eax
lock ; Make MP safe
inc dword [0x00000100] ; Increment AP processor count
; Jump to code that can
; Load real GDT
; Load task register
; Load IDT
jmp $-0
_mp_trampoline_end: