1 ;------------------------------------------------------------------------------ ;
2 ; Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
3 ; SPDX-License-Identifier: BSD-2-Clause-Patent
11 ; This is the assembly code for Multi-processor S3 support
13 ;-------------------------------------------------------------------------------
15 %define VacantFlag 0x0
16 %define NotVacantFlag 0xff
18 %define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart
19 %define StackStartAddressLocation LockLocation + 0x8
20 %define StackSizeLocation LockLocation + 0x10
21 %define CProcedureLocation LockLocation + 0x18
22 %define GdtrLocation LockLocation + 0x20
23 %define IdtrLocation LockLocation + 0x2A
24 %define BufferStartLocation LockLocation + 0x34
25 %define Cr3OffsetLocation LockLocation + 0x38
26 %define InitializeFloatingPointUnitsAddress LockLocation + 0x3C
28 ;-------------------------------------------------------------------------------------
29 ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
30 ;procedure serializes all the AP processors through an Init sequence. It must be
31 ;noted that APs arrive here very raw...ie: real mode, no stack.
32 ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
34 ;-------------------------------------------------------------------------------------
35 ;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
42 global ASM_PFX(RendezvousFunnelProc)
43 ASM_PFX(RendezvousFunnelProc):
44 RendezvousFunnelProcStart:
46 ; At this point CS = 0x(vv00) and ip= 0x0.
58 mov si, BufferStartLocation
59 mov edx,dword [si] ; EDX is keeping the start address of wakeup buffer
61 mov si, Cr3OffsetLocation
62 mov ecx,dword [si] ; ECX is keeping the value of CR3
73 mov eax, cr0 ; Get control register 0
74 or eax, 0x000000001 ; Set PE bit (bit #0)
79 a32 jmp dword 0x20:0x0
82 PMODE_ENTRY: ; protected mode entry point
89 o16 mov ss, ax ; Flat mode setup.
97 mov esi, edx ; Save wakeup buffer address
99 mov ecx, 0xc0000080 ; EFER MSR number.
101 bts eax, 8 ; Set LME=1.
104 mov eax, cr0 ; Read CR0.
105 bts eax, 31 ; Set PG=1.
106 mov cr0, eax ; Write CR0.
110 a16 jmp dword 0x38:0x0
121 add edi, LockLocation
122 mov al, NotVacantFlag
125 cmp al, NotVacantFlag
131 add edi, StackSizeLocation
134 add edi, StackStartAddressLocation
143 add edi, LockLocation
147 ; Call assembly function to initialize FPU.
149 mov rax, qword [esi + InitializeFloatingPointUnitsAddress]
158 add edi, CProcedureLocation
173 RendezvousFunnelProcEnd:
175 ;-------------------------------------------------------------------------------------
176 ; AsmGetAddressMap (&AddressMap);
177 ;-------------------------------------------------------------------------------------
178 ; comments here for definition of address map
179 global ASM_PFX(AsmGetAddressMap)
180 ASM_PFX(AsmGetAddressMap):
181 lea rax, [RendezvousFunnelProcStart]
183 mov qword [rcx+0x8], PMODE_ENTRY - RendezvousFunnelProcStart
184 mov qword [rcx+0x10], FLAT32_JUMP - RendezvousFunnelProcStart
185 mov qword [rcx+0x18], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
186 mov qword [rcx+0x20], LongModeStart - RendezvousFunnelProcStart
187 mov qword [rcx+0x28], LONG_JUMP - RendezvousFunnelProcStart