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