1 ;------------------------------------------------------------------------------ ;
2 ; Copyright (c) 2016, 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 extern ASM_PFX(InitializeFloatingPointUnits)
23 %define VacantFlag 0x0
24 %define NotVacantFlag 0xff
26 %define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart
27 %define StackStartAddressLocation LockLocation + 0x8
28 %define StackSizeLocation LockLocation + 0x10
29 %define CProcedureLocation LockLocation + 0x18
30 %define GdtrLocation LockLocation + 0x20
31 %define IdtrLocation LockLocation + 0x2A
32 %define BufferStartLocation LockLocation + 0x34
33 %define Cr3OffsetLocation LockLocation + 0x38
35 ;-------------------------------------------------------------------------------------
36 ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
37 ;procedure serializes all the AP processors through an Init sequence. It must be
38 ;noted that APs arrive here very raw...ie: real mode, no stack.
39 ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
41 ;-------------------------------------------------------------------------------------
42 ;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
49 global ASM_PFX(RendezvousFunnelProc)
50 ASM_PFX(RendezvousFunnelProc):
51 RendezvousFunnelProcStart:
53 ; At this point CS = 0x(vv00) and ip= 0x0.
65 mov si, BufferStartLocation
66 mov edx,dword [si] ; EDX is keeping the start address of wakeup buffer
68 mov si, Cr3OffsetLocation
69 mov ecx,dword [si] ; ECX is keeping the value of CR3
80 mov eax, cr0 ; Get control register 0
81 or eax, 0x000000001 ; Set PE bit (bit #0)
86 a32 jmp dword 0x20:0x0
89 PMODE_ENTRY: ; protected mode entry point
96 o16 mov ss, ax ; Flat mode setup.
104 mov esi, edx ; Save wakeup buffer address
106 mov ecx, 0xc0000080 ; EFER MSR number.
108 bts eax, 8 ; Set LME=1.
111 mov eax, cr0 ; Read CR0.
112 bts eax, 31 ; Set PG=1.
113 mov cr0, eax ; Write CR0.
117 a16 jmp dword 0x38:0x0
128 add edi, LockLocation
129 mov al, NotVacantFlag
132 cmp al, NotVacantFlag
138 add edi, StackSizeLocation
141 add edi, StackStartAddressLocation
150 add edi, LockLocation
154 ; Call assembly function to initialize FPU.
156 mov rax, ASM_PFX(InitializeFloatingPointUnits)
165 add edi, CProcedureLocation
180 RendezvousFunnelProcEnd:
182 ;-------------------------------------------------------------------------------------
183 ; AsmGetAddressMap (&AddressMap);
184 ;-------------------------------------------------------------------------------------
185 ; comments here for definition of address map
186 global ASM_PFX(AsmGetAddressMap)
187 ASM_PFX(AsmGetAddressMap):
188 mov rax, RendezvousFunnelProcStart
190 mov qword [rcx+0x8], PMODE_ENTRY - RendezvousFunnelProcStart
191 mov qword [rcx+0x10], FLAT32_JUMP - RendezvousFunnelProcStart
192 mov qword [rcx+0x18], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
193 mov qword [rcx+0x20], LongModeStart - RendezvousFunnelProcStart
194 mov qword [rcx+0x28], LONG_JUMP - RendezvousFunnelProcStart