]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/MpFuncs.nasm
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / Ia32 / MpFuncs.nasm
1 ;------------------------------------------------------------------------------ ;
2 ; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
3 ; SPDX-License-Identifier: BSD-2-Clause-Patent
4 ;
5 ; Module Name:
6 ;
7 ; MpFuncs.nasm
8 ;
9 ; Abstract:
10 ;
11 ; This is the assembly code for Multi-processor S3 support
12 ;
13 ;-------------------------------------------------------------------------------
14
15 SECTION .text
16
17 extern ASM_PFX(InitializeFloatingPointUnits)
18
19 %define VacantFlag 0x0
20 %define NotVacantFlag 0xff
21
22 %define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart
23 %define StackStart LockLocation + 0x4
24 %define StackSize LockLocation + 0x8
25 %define RendezvousProc LockLocation + 0xC
26 %define GdtrProfile LockLocation + 0x10
27 %define IdtrProfile LockLocation + 0x16
28 %define BufferStart LockLocation + 0x1C
29
30 ;-------------------------------------------------------------------------------------
31 ;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
32 ;procedure serializes all the AP processors through an Init sequence. It must be
33 ;noted that APs arrive here very raw...ie: real mode, no stack.
34 ;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
35 ;IS IN MACHINE CODE.
36 ;-------------------------------------------------------------------------------------
37 ;RendezvousFunnelProc (&WakeUpBuffer,MemAddress);
38
39 BITS 16
40 global ASM_PFX(RendezvousFunnelProc)
41 ASM_PFX(RendezvousFunnelProc):
42 RendezvousFunnelProcStart:
43
44 ; At this point CS = 0x(vv00) and ip= 0x0.
45
46 mov ax, cs
47 mov ds, ax
48 mov es, ax
49 mov ss, ax
50 xor ax, ax
51 mov fs, ax
52 mov gs, ax
53
54 flat32Start:
55
56 mov si, BufferStart
57 mov edx,dword [si] ; EDX is keeping the start address of wakeup buffer
58
59 mov si, GdtrProfile
60 o32 lgdt [cs:si]
61
62 mov si, IdtrProfile
63 o32 lidt [cs:si]
64
65 xor ax, ax
66 mov ds, ax
67
68 mov eax, cr0 ; Get control register 0
69 or eax, 0x000000001 ; Set PE bit (bit #0)
70 mov cr0, eax
71
72 FLAT32_JUMP:
73
74 a32 jmp dword 0x20:0x0
75
76 BITS 32
77 PMODE_ENTRY: ; protected mode entry point
78
79 mov ax, 0x8
80 o16 mov ds, ax
81 o16 mov es, ax
82 o16 mov fs, ax
83 o16 mov gs, ax
84 o16 mov ss, ax ; Flat mode setup.
85
86 mov esi, edx
87
88 mov edi, esi
89 add edi, LockLocation
90 mov al, NotVacantFlag
91 TestLock:
92 xchg byte [edi], al
93 cmp al, NotVacantFlag
94 jz TestLock
95
96 ProgramStack:
97
98 mov edi, esi
99 add edi, StackSize
100 mov eax, dword [edi]
101 mov edi, esi
102 add edi, StackStart
103 add eax, dword [edi]
104 mov esp, eax
105 mov dword [edi], eax
106
107 Releaselock:
108
109 mov al, VacantFlag
110 mov edi, esi
111 add edi, LockLocation
112 xchg byte [edi], al
113
114 ;
115 ; Call assembly function to initialize FPU.
116 ;
117 mov ebx, ASM_PFX(InitializeFloatingPointUnits)
118 call ebx
119 ;
120 ; Call C Function
121 ;
122 mov edi, esi
123 add edi, RendezvousProc
124 mov eax, dword [edi]
125
126 test eax, eax
127 jz GoToSleep
128 call eax ; Call C function
129
130 GoToSleep:
131 cli
132 hlt
133 jmp $-2
134
135 RendezvousFunnelProcEnd:
136 ;-------------------------------------------------------------------------------------
137 ; AsmGetAddressMap (&AddressMap);
138 ;-------------------------------------------------------------------------------------
139 global ASM_PFX(AsmGetAddressMap)
140 ASM_PFX(AsmGetAddressMap):
141
142 pushad
143 mov ebp,esp
144
145 mov ebx, dword [ebp+0x24]
146 mov dword [ebx], RendezvousFunnelProcStart
147 mov dword [ebx+0x4], PMODE_ENTRY - RendezvousFunnelProcStart
148 mov dword [ebx+0x8], FLAT32_JUMP - RendezvousFunnelProcStart
149 mov dword [ebx+0xc], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
150
151 popad
152 ret
153