1 ;------------------------------------------------------------------------------ ;
2 ; Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
3 ; This program and the accompanying materials
4 ; are licensed and made available under the terms and conditions of the BSD License
5 ; which accompanies this distribution. The full text of the license may be found at
6 ; http://opensource.org/licenses/bsd-license.php.
8 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 ; This is the assembly code for MP support
19 ;-------------------------------------------------------------------------------
27 ;-------------------------------------------------------------------------------------
28 ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
29 ;procedure serializes all the AP processors through an Init sequence. It must be
30 ;noted that APs arrive here very raw...ie: real mode, no stack.
31 ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
33 ;-------------------------------------------------------------------------------------
34 global ASM_PFX(RendezvousFunnelProc)
35 ASM_PFX(RendezvousFunnelProc):
36 RendezvousFunnelProcStart:
37 ; At this point CS = 0x(vv00) and ip= 0x0.
38 ; Save BIST information to ebp firstly
42 mov ebp, eax ; save BIST information
52 mov si, BufferStartLocation
55 mov di, PmodeOffsetLocation
62 mov di, LmodeOffsetLocation
71 mov ecx,[si] ; ECX is keeping the value of CR3
83 mov eax, cr0 ;Get control register 0
84 or eax, 000000003h ;Set PE bit (bit #0) & MP
87 jmp PROTECT_MODE_CS:strict dword 0 ; far jump to protected mode
89 Flat32Start: ; protected mode entry point
90 mov ax, PROTECT_MODE_DS
104 mov ecx, 0c0000080h ; EFER MSR number.
106 bts eax, 8 ; Set LME=1.
109 mov eax, cr0 ; Read CR0.
110 bts eax, 31 ; Set PG=1.
111 mov cr0, eax ; Write CR0.
113 jmp LONG_MODE_CS:strict dword 0 ; far jump to long mode
123 add edi, LockLocation
124 mov rax, NotVacantFlag
127 xchg qword [edi], rax
128 cmp rax, NotVacantFlag
132 add edi, NumApsExecutingLoction
138 add edi, StackSizeLocation
141 add edi, StackStartAddressLocation
149 add edi, LockLocation
150 xchg qword [edi], rax
153 push rbp ; push BIST data at top of AP stack
154 xor rbp, rbp ; clear ebp for call stack trace
159 mov edx, ebx ; edx is NumApsExecuting
161 add ecx, LockLocation ; rcx is address of exchange info data buffer
164 add edi, ApProcedureLocation
168 call rax ; invoke C function
171 RendezvousFunnelProcEnd:
174 global ASM_PFX(AsmInitializeGdt)
175 ASM_PFX(AsmInitializeGdt):
179 lgdt [rcx] ; update the GDTR
182 mov rax, ASM_PFX(SetCodeSelectorFarJump)
184 mov rdx, LONG_MODE_CS
185 mov [rsp + 4], dx ; get new CS
186 jmp far dword [rsp] ; far jump with new CS
187 ASM_PFX(SetCodeSelectorFarJump):
190 mov rax, LONG_MODE_DS ; get new DS