1 ;------------------------------------------------------------------------------
2 ; IA32 assembly file for AP startup vector.
4 ; Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
5 ; This program and the accompanying materials
6 ; are licensed and made available under the terms and conditions of the BSD License
7 ; which accompanies this distribution. The full text of the license may be found at
8 ; http://opensource.org/licenses/bsd-license.php
10 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 ;------------------------------------------------------------------------------
19 include AsmInclude.inc
20 ;-------------------------------------------------------------------------------------
21 FJMP32 MACRO Selector, Offset
25 DD Offset ; 32-bit offset
26 DW Selector ; 16-bit selector
29 ;-------------------------------------------------------------------------------------
30 ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
31 ;procedure serializes all the AP processors through an Init sequence. It must be
32 ;noted that APs arrive here very raw...ie: real mode, no stack.
33 ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
35 ;-------------------------------------------------------------------------------------
36 ;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
38 RendezvousFunnelProc PROC near C PUBLIC
39 RendezvousFunnelProcStart::
42 ; At this point CS = 0x(vv00) and ip= 0x0.
44 db 8ch, 0c8h ; mov ax, cs
45 db 8eh, 0d8h ; mov ds, ax
46 db 8eh, 0c0h ; mov es, ax
47 db 8eh, 0d0h ; mov ss, ax
48 db 33h, 0c0h ; xor ax, ax
49 db 8eh, 0e0h ; mov fs, ax
50 db 8eh, 0e8h ; mov gs, ax
52 ; Switch to flat mode.
55 dw BufferStart ; mov si, BufferStart
56 db 66h, 8Bh, 0Ch ; mov ecx,dword ptr [si] ; ECX is keeping the start address of wakeup buffer
60 dw GdtrProfile ; mov si, GdtrProfile
62 db 2Eh,0Fh, 01h, 14h ; lgdt fword ptr cs:[si]
65 dw IdtrProfile ; mov si, IdtrProfile
67 db 2Eh,0Fh, 01h, 1Ch ; lidt fword ptr cs:[si]
69 db 33h, 0C0h ; xor ax, ax
70 db 8Eh, 0D8h ; mov ds, ax
71 db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0
72 db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0)
73 db 0Fh, 22h, 0C0h ; mov cr0, eax
77 FJMP32 010h,0h ; Far jmp using code segment descriptor
79 ProtectedModeStart:: ; protected mode entry point
86 mov ss, ax ; Flat mode setup.
91 mov ecx, 1bh ; Read IA32_APIC_BASE MSR
94 bt eax, 10 ; Check for x2apic mode
96 mov ecx, 802h ; Read APIC_ID
98 mov ebx, eax ; ebx == apicid
105 mov ebx, dword ptr [eax]
106 shr ebx, 24 ; ebx == apicid
112 add edi, ProcessorNumber
113 mov ecx, dword ptr [edi + 4 * ebx] ; ECX = CpuNumber
117 mov eax, dword ptr [edi]
119 mul ecx ; EAX = StackSize * (CpuNumber + 1)
123 mov ebx, dword ptr [edi]
124 add eax, ebx ; EAX = StackStart + StackSize * (CpuNumber + 1)
132 add edi, RendezvousProc
133 mov ebx, dword ptr [edi]
137 call ebx ; Call C function
145 RendezvousFunnelProc ENDP
146 RendezvousFunnelProcEnd::
147 ;-------------------------------------------------------------------------------------
148 ; AsmGetAddressMap (&AddressMap);
149 ;-------------------------------------------------------------------------------------
150 AsmGetAddressMap PROC near C PUBLIC
155 mov ebx, dword ptr [ebp+24h]
156 mov dword ptr [ebx], RendezvousFunnelProcStart
157 mov dword ptr [ebx+4h], ProtectedModeStart - RendezvousFunnelProcStart
158 mov dword ptr [ebx+8h], FLAT32_JUMP - RendezvousFunnelProcStart
159 mov dword ptr [ebx+0ch], 0
160 mov dword ptr [ebx+10h], 0
161 mov dword ptr [ebx+14h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
165 AsmGetAddressMap ENDP