1 ;------------------------------------------------------------------------------
2 ; X64 assembly file for AP startup vector.
4 ; Copyright (c) 2009, Intel Corporation
5 ; All rights reserved. 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 ;------------------------------------------------------------------------------
17 include AsmInclude.inc
18 ;-------------------------------------------------------------------------------------
20 ;-------------------------------------------------------------------------------------
21 ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
22 ;procedure serializes all the AP processors through an Init sequence. It must be
23 ;noted that APs arrive here very raw...ie: real mode, no stack.
24 ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
26 ;-------------------------------------------------------------------------------------
27 ;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
29 RendezvousFunnelProc PROC PUBLIC
30 RendezvousFunnelProcStart::
32 ; At this point CS = 0x(vv00) and ip= 0x0.
34 db 8ch, 0c8h ; mov ax, cs
35 db 8eh, 0d8h ; mov ds, ax
36 db 8eh, 0c0h ; mov es, ax
37 db 8eh, 0d0h ; mov ss, ax
38 db 33h, 0c0h ; xor ax, ax
39 db 8eh, 0e0h ; mov fs, ax
40 db 8eh, 0e8h ; mov gs, ax
42 ; Switch to flat mode.
45 dw BufferStartLocation ; mov si, BufferStartLocation
46 db 66h, 8Bh, 14h ; mov edx,dword ptr [si] ; EDX is keeping the start address of wakeup buffer
49 dw Cr3OffsetLocation ; mov si, Cr3Location
50 db 66h, 8Bh, 0Ch ; mov ecx,dword ptr [si] ; ECX is keeping the value of CR3
53 dw GdtrLocation ; mov si, GdtrProfile
55 db 2Eh, 0Fh, 01h, 14h ; lgdt fword ptr cs:[si]
57 db 33h, 0C0h ; xor ax, ax
58 db 8Eh, 0D8h ; mov ds, ax
60 db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Get control register 0
61 db 66h, 83h, 0C8h, 01h ; or eax, 000000001h ; Set PE bit (bit #0)
62 db 0Fh, 22h, 0C0h ; mov cr0, eax
66 db 66h, 67h, 0EAh ; far jump
68 dw 20h ; 16-bit selector
72 db 66h, 0B8h, 18h, 00h ; mov ax, 18h
73 db 66h, 8Eh, 0D8h ; mov ds, ax
74 db 66h, 8Eh, 0C0h ; mov es, ax
75 db 66h, 8Eh, 0E0h ; mov fs, ax
76 db 66h, 8Eh, 0E8h ; mov gs, ax
77 db 66h, 8Eh, 0D0h ; mov ss, ax ; Flat mode setup.
79 db 0Fh, 20h, 0E0h ; mov eax, cr4
80 db 0Fh, 0BAh, 0E8h, 05h ; bts eax, 5
81 db 0Fh, 22h, 0E0h ; mov cr4, eax
83 db 0Fh, 22h, 0D9h ; mov cr3, ecx
85 db 8Bh, 0F2h ; mov esi, edx ; Save wakeup buffer address
88 dd 0C0000080h ; mov ecx, 0c0000080h ; EFER MSR number.
89 db 0Fh, 32h ; rdmsr ; Read EFER.
90 db 0Fh, 0BAh, 0E8h, 08h ; bts eax, 8 ; Set LME=1.
91 db 0Fh, 30h ; wrmsr ; Write EFER.
93 db 0Fh, 20h, 0C0h ; mov eax, cr0 ; Read CR0.
94 db 0Fh, 0BAh, 0E8h, 1Fh ; bts eax, 31 ; Set PG=1.
95 db 0Fh, 22h, 0C0h ; mov cr0, eax ; Write CR0.
99 db 67h, 0EAh ; far jump
100 dd 0h ; 32-bit offset
101 dw 38h ; 16-bit selector
111 add edi, LockLocation
112 mov al, NotVacantFlag
114 xchg byte ptr [edi], al
115 cmp al, NotVacantFlag
121 add edi, StackSizeLocation
122 mov rax, qword ptr [edi]
124 add edi, StackStartAddressLocation
125 add rax, qword ptr [edi]
127 mov qword ptr [edi], rax
133 add edi, LockLocation
134 xchg byte ptr [edi], al
140 add edi, CProcedureLocation
141 mov rax, qword ptr [edi]
156 RendezvousFunnelProc ENDP
157 RendezvousFunnelProcEnd::
160 ;-------------------------------------------------------------------------------------
161 ; AsmGetAddressMap (&AddressMap);
162 ;-------------------------------------------------------------------------------------
163 AsmGetAddressMap PROC
165 mov rax, offset RendezvousFunnelProcStart
166 mov qword ptr [rcx], rax
167 mov qword ptr [rcx+8h], ProtectedModeStart - RendezvousFunnelProcStart
168 mov qword ptr [rcx+10h], FLAT32_JUMP - RendezvousFunnelProcStart
169 mov qword ptr [rcx+18h], LongModeStart - RendezvousFunnelProcStart
170 mov qword ptr [rcx+20h], LONG_JUMP - RendezvousFunnelProcStart
171 mov qword ptr [rcx+28h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
175 AsmGetAddressMap ENDP