1 ;------------------------------------------------------------------------------ ;
2 ; Copyright (c) 2016 - 2018, 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 Multi-processor S3 support
19 ;-------------------------------------------------------------------------------
21 %define VacantFlag 0x0
22 %define NotVacantFlag 0xff
24 %define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart
25 %define StackStartAddressLocation LockLocation + 0x8
26 %define StackSizeLocation LockLocation + 0x10
27 %define CProcedureLocation LockLocation + 0x18
28 %define GdtrLocation LockLocation + 0x20
29 %define IdtrLocation LockLocation + 0x2A
30 %define BufferStartLocation LockLocation + 0x34
31 %define Cr3OffsetLocation LockLocation + 0x38
32 %define InitializeFloatingPointUnitsAddress LockLocation + 0x3C
34 ;-------------------------------------------------------------------------------------
35 ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
36 ;procedure serializes all the AP processors through an Init sequence. It must be
37 ;noted that APs arrive here very raw...ie: real mode, no stack.
38 ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
40 ;-------------------------------------------------------------------------------------
41 ;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
48 global ASM_PFX(RendezvousFunnelProc)
49 ASM_PFX(RendezvousFunnelProc):
50 RendezvousFunnelProcStart:
52 ; At this point CS = 0x(vv00) and ip= 0x0.
64 mov si, BufferStartLocation
65 mov edx,dword [si] ; EDX is keeping the start address of wakeup buffer
67 mov si, Cr3OffsetLocation
68 mov ecx,dword [si] ; ECX is keeping the value of CR3
79 mov eax, cr0 ; Get control register 0
80 or eax, 0x000000001 ; Set PE bit (bit #0)
85 a32 jmp dword 0x20:0x0
88 PMODE_ENTRY: ; protected mode entry point
95 o16 mov ss, ax ; Flat mode setup.
103 mov esi, edx ; Save wakeup buffer address
105 mov ecx, 0xc0000080 ; EFER MSR number.
107 bts eax, 8 ; Set LME=1.
110 mov eax, cr0 ; Read CR0.
111 bts eax, 31 ; Set PG=1.
112 mov cr0, eax ; Write CR0.
116 a16 jmp dword 0x38:0x0
127 add edi, LockLocation
128 mov al, NotVacantFlag
131 cmp al, NotVacantFlag
137 add edi, StackSizeLocation
140 add edi, StackStartAddressLocation
149 add edi, LockLocation
153 ; Call assembly function to initialize FPU.
155 mov rax, qword [esi + InitializeFloatingPointUnitsAddress]
164 add edi, CProcedureLocation
179 RendezvousFunnelProcEnd:
181 ;-------------------------------------------------------------------------------------
182 ; AsmGetAddressMap (&AddressMap);
183 ;-------------------------------------------------------------------------------------
184 ; comments here for definition of address map
185 global ASM_PFX(AsmGetAddressMap)
186 ASM_PFX(AsmGetAddressMap):
187 lea rax, [RendezvousFunnelProcStart]
189 mov qword [rcx+0x8], PMODE_ENTRY - RendezvousFunnelProcStart
190 mov qword [rcx+0x10], FLAT32_JUMP - RendezvousFunnelProcStart
191 mov qword [rcx+0x18], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
192 mov qword [rcx+0x20], LongModeStart - RendezvousFunnelProcStart
193 mov qword [rcx+0x28], LONG_JUMP - RendezvousFunnelProcStart