]>
Commit | Line | Data |
---|---|---|
529a5a86 MK |
1 | /** @file\r |
2 | Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU.\r | |
3 | \r | |
f85d3ce2 | 4 | Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r |
529a5a86 MK |
5 | This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _CPU_PISMMCPUDXESMM_H_\r | |
16 | #define _CPU_PISMMCPUDXESMM_H_\r | |
17 | \r | |
18 | #include <PiSmm.h>\r | |
19 | \r | |
20 | #include <Protocol/MpService.h>\r | |
21 | #include <Protocol/SmmConfiguration.h>\r | |
22 | #include <Protocol/SmmCpu.h>\r | |
23 | #include <Protocol/SmmAccess2.h>\r | |
529a5a86 MK |
24 | #include <Protocol/SmmReadyToLock.h>\r |
25 | #include <Protocol/SmmCpuService.h>\r | |
26 | \r | |
27 | #include <Guid/AcpiS3Context.h>\r | |
717fb604 | 28 | #include <Guid/PiSmmMemoryAttributesTable.h>\r |
529a5a86 MK |
29 | \r |
30 | #include <Library/BaseLib.h>\r | |
31 | #include <Library/IoLib.h>\r | |
32 | #include <Library/TimerLib.h>\r | |
529a5a86 MK |
33 | #include <Library/SynchronizationLib.h>\r |
34 | #include <Library/DebugLib.h>\r | |
35 | #include <Library/BaseMemoryLib.h>\r | |
36 | #include <Library/PcdLib.h>\r | |
37 | #include <Library/CacheMaintenanceLib.h>\r | |
38 | #include <Library/MtrrLib.h>\r | |
39 | #include <Library/SmmCpuPlatformHookLib.h>\r | |
40 | #include <Library/SmmServicesTableLib.h>\r | |
41 | #include <Library/MemoryAllocationLib.h>\r | |
42 | #include <Library/UefiBootServicesTableLib.h>\r | |
43 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
44 | #include <Library/DebugAgentLib.h>\r | |
45 | #include <Library/HobLib.h>\r | |
46 | #include <Library/LocalApicLib.h>\r | |
47 | #include <Library/UefiCpuLib.h>\r | |
48 | #include <Library/CpuExceptionHandlerLib.h>\r | |
49 | #include <Library/ReportStatusCodeLib.h>\r | |
50 | #include <Library/SmmCpuFeaturesLib.h>\r | |
51 | #include <Library/PeCoffGetEntryPointLib.h>\r | |
52 | \r | |
53 | #include <AcpiCpuData.h>\r | |
54 | #include <CpuHotPlugData.h>\r | |
55 | \r | |
56 | #include <Register/Cpuid.h>\r | |
f85d3ce2 | 57 | #include <Register/Msr.h>\r |
529a5a86 MK |
58 | \r |
59 | #include "CpuService.h"\r | |
60 | #include "SmmProfile.h"\r | |
61 | \r | |
62 | //\r | |
63 | // MSRs required for configuration of SMM Code Access Check\r | |
64 | //\r | |
65 | #define EFI_MSR_SMM_MCA_CAP 0x17D\r | |
66 | #define SMM_CODE_ACCESS_CHK_BIT BIT58\r | |
67 | \r | |
68 | #define SMM_FEATURE_CONTROL_LOCK_BIT BIT0\r | |
69 | #define SMM_CODE_CHK_EN_BIT BIT2\r | |
70 | \r | |
71 | ///\r | |
72 | /// Page Table Entry\r | |
73 | ///\r | |
74 | #define IA32_PG_P BIT0\r | |
75 | #define IA32_PG_RW BIT1\r | |
881520ea | 76 | #define IA32_PG_U BIT2\r |
529a5a86 MK |
77 | #define IA32_PG_WT BIT3\r |
78 | #define IA32_PG_CD BIT4\r | |
79 | #define IA32_PG_A BIT5\r | |
881520ea | 80 | #define IA32_PG_D BIT6\r |
529a5a86 MK |
81 | #define IA32_PG_PS BIT7\r |
82 | #define IA32_PG_PAT_2M BIT12\r | |
83 | #define IA32_PG_PAT_4K IA32_PG_PS\r | |
84 | #define IA32_PG_PMNT BIT62\r | |
85 | #define IA32_PG_NX BIT63\r | |
86 | \r | |
717fb604 | 87 | #define PAGE_ATTRIBUTE_BITS (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P)\r |
881520ea JY |
88 | //\r |
89 | // Bits 1, 2, 5, 6 are reserved in the IA32 PAE PDPTE\r | |
90 | // X64 PAE PDPTE does not have such restriction\r | |
91 | //\r | |
92 | #define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P)\r | |
93 | \r | |
717fb604 JY |
94 | #define PAGE_PROGATE_BITS (IA32_PG_NX | PAGE_ATTRIBUTE_BITS)\r |
95 | \r | |
96 | #define PAGING_4K_MASK 0xFFF\r | |
97 | #define PAGING_2M_MASK 0x1FFFFF\r | |
98 | #define PAGING_1G_MASK 0x3FFFFFFF\r | |
99 | \r | |
100 | #define PAGING_PAE_INDEX_MASK 0x1FF\r | |
101 | \r | |
102 | #define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull\r | |
103 | #define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull\r | |
104 | #define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull\r | |
105 | \r | |
106 | typedef enum {\r | |
107 | PageNone,\r | |
108 | Page4K,\r | |
109 | Page2M,\r | |
110 | Page1G,\r | |
111 | } PAGE_ATTRIBUTE;\r | |
112 | \r | |
113 | typedef struct {\r | |
114 | PAGE_ATTRIBUTE Attribute;\r | |
115 | UINT64 Length;\r | |
116 | UINT64 AddressMask;\r | |
117 | } PAGE_ATTRIBUTE_TABLE;\r | |
118 | \r | |
529a5a86 MK |
119 | //\r |
120 | // Size of Task-State Segment defined in IA32 Manual\r | |
121 | //\r | |
122 | #define TSS_SIZE 104\r | |
123 | #define TSS_X64_IST1_OFFSET 36\r | |
124 | #define TSS_IA32_CR3_OFFSET 28\r | |
125 | #define TSS_IA32_ESP_OFFSET 56\r | |
126 | \r | |
717fb604 JY |
127 | #define CR0_WP BIT16\r |
128 | \r | |
529a5a86 MK |
129 | //\r |
130 | // Code select value\r | |
131 | //\r | |
132 | #define PROTECT_MODE_CODE_SEGMENT 0x08\r | |
133 | #define LONG_MODE_CODE_SEGMENT 0x38\r | |
134 | \r | |
135 | //\r | |
136 | // The size 0x20 must be bigger than\r | |
137 | // the size of template code of SmmInit. Currently,\r | |
138 | // the size of SmmInit requires the 0x16 Bytes buffer\r | |
139 | // at least.\r | |
140 | //\r | |
141 | #define BACK_BUF_SIZE 0x20\r | |
142 | \r | |
143 | #define EXCEPTION_VECTOR_NUMBER 0x20\r | |
144 | \r | |
145 | #define INVALID_APIC_ID 0xFFFFFFFFFFFFFFFFULL\r | |
146 | \r | |
147 | typedef UINT32 SMM_CPU_ARRIVAL_EXCEPTIONS;\r | |
148 | #define ARRIVAL_EXCEPTION_BLOCKED 0x1\r | |
149 | #define ARRIVAL_EXCEPTION_DELAYED 0x2\r | |
150 | #define ARRIVAL_EXCEPTION_SMI_DISABLED 0x4\r | |
151 | \r | |
152 | //\r | |
153 | // Private structure for the SMM CPU module that is stored in DXE Runtime memory\r | |
154 | // Contains the SMM Configuration Protocols that is produced.\r | |
155 | // Contains a mix of DXE and SMM contents. All the fields must be used properly.\r | |
156 | //\r | |
157 | #define SMM_CPU_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('s', 'c', 'p', 'u')\r | |
158 | \r | |
159 | typedef struct {\r | |
160 | UINTN Signature;\r | |
161 | \r | |
162 | EFI_HANDLE SmmCpuHandle;\r | |
163 | \r | |
164 | EFI_PROCESSOR_INFORMATION *ProcessorInfo;\r | |
165 | SMM_CPU_OPERATION *Operation;\r | |
166 | UINTN *CpuSaveStateSize;\r | |
167 | VOID **CpuSaveState;\r | |
168 | \r | |
169 | EFI_SMM_RESERVED_SMRAM_REGION SmmReservedSmramRegion[1];\r | |
170 | EFI_SMM_ENTRY_CONTEXT SmmCoreEntryContext;\r | |
171 | EFI_SMM_ENTRY_POINT SmmCoreEntry;\r | |
172 | \r | |
173 | EFI_SMM_CONFIGURATION_PROTOCOL SmmConfiguration;\r | |
174 | } SMM_CPU_PRIVATE_DATA;\r | |
175 | \r | |
176 | extern SMM_CPU_PRIVATE_DATA *gSmmCpuPrivate;\r | |
177 | extern CPU_HOT_PLUG_DATA mCpuHotPlugData;\r | |
178 | extern UINTN mMaxNumberOfCpus;\r | |
179 | extern UINTN mNumberOfCpus;\r | |
529a5a86 MK |
180 | extern EFI_SMM_CPU_PROTOCOL mSmmCpu;\r |
181 | \r | |
182 | ///\r | |
183 | /// The mode of the CPU at the time an SMI occurs\r | |
184 | ///\r | |
185 | extern UINT8 mSmmSaveStateRegisterLma;\r | |
186 | \r | |
187 | \r | |
188 | //\r | |
189 | // SMM CPU Protocol function prototypes.\r | |
190 | //\r | |
191 | \r | |
192 | /**\r | |
193 | Read information from the CPU save state.\r | |
194 | \r | |
195 | @param This EFI_SMM_CPU_PROTOCOL instance\r | |
196 | @param Width The number of bytes to read from the CPU save state.\r | |
197 | @param Register Specifies the CPU register to read form the save state.\r | |
198 | @param CpuIndex Specifies the zero-based index of the CPU save state\r | |
199 | @param Buffer Upon return, this holds the CPU register value read from the save state.\r | |
200 | \r | |
201 | @retval EFI_SUCCESS The register was read from Save State\r | |
202 | @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor\r | |
203 | @retval EFI_INVALID_PARAMTER This or Buffer is NULL.\r | |
204 | \r | |
205 | **/\r | |
206 | EFI_STATUS\r | |
207 | EFIAPI\r | |
208 | SmmReadSaveState (\r | |
209 | IN CONST EFI_SMM_CPU_PROTOCOL *This,\r | |
210 | IN UINTN Width,\r | |
211 | IN EFI_SMM_SAVE_STATE_REGISTER Register,\r | |
212 | IN UINTN CpuIndex,\r | |
213 | OUT VOID *Buffer\r | |
214 | );\r | |
215 | \r | |
216 | /**\r | |
217 | Write data to the CPU save state.\r | |
218 | \r | |
219 | @param This EFI_SMM_CPU_PROTOCOL instance\r | |
220 | @param Width The number of bytes to read from the CPU save state.\r | |
221 | @param Register Specifies the CPU register to write to the save state.\r | |
222 | @param CpuIndex Specifies the zero-based index of the CPU save state\r | |
223 | @param Buffer Upon entry, this holds the new CPU register value.\r | |
224 | \r | |
225 | @retval EFI_SUCCESS The register was written from Save State\r | |
226 | @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor\r | |
227 | @retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct\r | |
228 | \r | |
229 | **/\r | |
230 | EFI_STATUS\r | |
231 | EFIAPI\r | |
232 | SmmWriteSaveState (\r | |
233 | IN CONST EFI_SMM_CPU_PROTOCOL *This,\r | |
234 | IN UINTN Width,\r | |
235 | IN EFI_SMM_SAVE_STATE_REGISTER Register,\r | |
236 | IN UINTN CpuIndex,\r | |
237 | IN CONST VOID *Buffer\r | |
238 | );\r | |
239 | \r | |
240 | /**\r | |
241 | Read a CPU Save State register on the target processor.\r | |
242 | \r | |
243 | This function abstracts the differences that whether the CPU Save State register is in the\r | |
244 | IA32 CPU Save State Map or X64 CPU Save State Map.\r | |
245 | \r | |
246 | This function supports reading a CPU Save State register in SMBase relocation handler.\r | |
247 | \r | |
248 | @param[in] CpuIndex Specifies the zero-based index of the CPU save state.\r | |
249 | @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table.\r | |
250 | @param[in] Width The number of bytes to read from the CPU save state.\r | |
251 | @param[out] Buffer Upon return, this holds the CPU register value read from the save state.\r | |
252 | \r | |
253 | @retval EFI_SUCCESS The register was read from Save State.\r | |
254 | @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor.\r | |
255 | @retval EFI_INVALID_PARAMTER This or Buffer is NULL.\r | |
256 | \r | |
257 | **/\r | |
258 | EFI_STATUS\r | |
259 | EFIAPI\r | |
260 | ReadSaveStateRegister (\r | |
261 | IN UINTN CpuIndex,\r | |
262 | IN EFI_SMM_SAVE_STATE_REGISTER Register,\r | |
263 | IN UINTN Width,\r | |
264 | OUT VOID *Buffer\r | |
265 | );\r | |
266 | \r | |
267 | /**\r | |
268 | Write value to a CPU Save State register on the target processor.\r | |
269 | \r | |
270 | This function abstracts the differences that whether the CPU Save State register is in the\r | |
271 | IA32 CPU Save State Map or X64 CPU Save State Map.\r | |
272 | \r | |
273 | This function supports writing a CPU Save State register in SMBase relocation handler.\r | |
274 | \r | |
275 | @param[in] CpuIndex Specifies the zero-based index of the CPU save state.\r | |
276 | @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table.\r | |
277 | @param[in] Width The number of bytes to read from the CPU save state.\r | |
278 | @param[in] Buffer Upon entry, this holds the new CPU register value.\r | |
279 | \r | |
280 | @retval EFI_SUCCESS The register was written to Save State.\r | |
281 | @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor.\r | |
282 | @retval EFI_INVALID_PARAMTER ProcessorIndex or Width is not correct.\r | |
283 | \r | |
284 | **/\r | |
285 | EFI_STATUS\r | |
286 | EFIAPI\r | |
287 | WriteSaveStateRegister (\r | |
288 | IN UINTN CpuIndex,\r | |
289 | IN EFI_SMM_SAVE_STATE_REGISTER Register,\r | |
290 | IN UINTN Width,\r | |
291 | IN CONST VOID *Buffer\r | |
292 | );\r | |
293 | \r | |
294 | //\r | |
295 | //\r | |
296 | //\r | |
297 | typedef struct {\r | |
298 | UINT32 Offset;\r | |
299 | UINT16 Segment;\r | |
300 | UINT16 Reserved;\r | |
301 | } IA32_FAR_ADDRESS;\r | |
302 | \r | |
303 | extern IA32_FAR_ADDRESS gSmmJmpAddr;\r | |
304 | \r | |
305 | extern CONST UINT8 gcSmmInitTemplate[];\r | |
306 | extern CONST UINT16 gcSmmInitSize;\r | |
307 | extern UINT32 gSmmCr0;\r | |
308 | extern UINT32 gSmmCr3;\r | |
309 | extern UINT32 gSmmCr4;\r | |
310 | extern UINTN gSmmInitStack;\r | |
311 | \r | |
312 | /**\r | |
313 | Semaphore operation for all processor relocate SMMBase.\r | |
314 | **/\r | |
315 | VOID\r | |
316 | EFIAPI\r | |
317 | SmmRelocationSemaphoreComplete (\r | |
318 | VOID\r | |
319 | );\r | |
320 | \r | |
321 | ///\r | |
322 | /// The type of SMM CPU Information\r | |
323 | ///\r | |
324 | typedef struct {\r | |
ed3d5ecb | 325 | SPIN_LOCK *Busy;\r |
529a5a86 MK |
326 | volatile EFI_AP_PROCEDURE Procedure;\r |
327 | volatile VOID *Parameter;\r | |
ed3d5ecb JF |
328 | volatile UINT32 *Run;\r |
329 | volatile BOOLEAN *Present;\r | |
529a5a86 MK |
330 | } SMM_CPU_DATA_BLOCK;\r |
331 | \r | |
332 | typedef enum {\r | |
333 | SmmCpuSyncModeTradition,\r | |
334 | SmmCpuSyncModeRelaxedAp,\r | |
335 | SmmCpuSyncModeMax\r | |
336 | } SMM_CPU_SYNC_MODE;\r | |
337 | \r | |
338 | typedef struct {\r | |
339 | //\r | |
340 | // Pointer to an array. The array should be located immediately after this structure\r | |
341 | // so that UC cache-ability can be set together.\r | |
342 | //\r | |
343 | SMM_CPU_DATA_BLOCK *CpuData;\r | |
fe3a75bc | 344 | volatile UINT32 *Counter;\r |
529a5a86 | 345 | volatile UINT32 BspIndex;\r |
fe3a75bc JF |
346 | volatile BOOLEAN *InsideSmm;\r |
347 | volatile BOOLEAN *AllCpusInSync;\r | |
529a5a86 MK |
348 | volatile SMM_CPU_SYNC_MODE EffectiveSyncMode;\r |
349 | volatile BOOLEAN SwitchBsp;\r | |
350 | volatile BOOLEAN *CandidateBsp;\r | |
351 | } SMM_DISPATCHER_MP_SYNC_DATA;\r | |
352 | \r | |
695e62d1 JF |
353 | #define MSR_SPIN_LOCK_INIT_NUM 15\r |
354 | \r | |
529a5a86 | 355 | typedef struct {\r |
dc99315b | 356 | SPIN_LOCK *SpinLock;\r |
529a5a86 MK |
357 | UINT32 MsrIndex;\r |
358 | } MP_MSR_LOCK;\r | |
359 | \r | |
360 | #define SMM_PSD_OFFSET 0xfb00\r | |
361 | \r | |
1d648531 JF |
362 | ///\r |
363 | /// All global semaphores' pointer\r | |
364 | ///\r | |
365 | typedef struct {\r | |
366 | volatile UINT32 *Counter;\r | |
367 | volatile BOOLEAN *InsideSmm;\r | |
368 | volatile BOOLEAN *AllCpusInSync;\r | |
369 | SPIN_LOCK *PFLock;\r | |
370 | SPIN_LOCK *CodeAccessCheckLock;\r | |
6c4c15fa | 371 | SPIN_LOCK *MemoryMappedLock;\r |
1d648531 JF |
372 | } SMM_CPU_SEMAPHORE_GLOBAL;\r |
373 | \r | |
4e920581 JF |
374 | ///\r |
375 | /// All semaphores for each processor\r | |
376 | ///\r | |
377 | typedef struct {\r | |
378 | SPIN_LOCK *Busy;\r | |
379 | volatile UINT32 *Run;\r | |
380 | volatile BOOLEAN *Present;\r | |
381 | } SMM_CPU_SEMAPHORE_CPU;\r | |
382 | \r | |
695e62d1 JF |
383 | ///\r |
384 | /// All MSRs semaphores' pointer and counter\r | |
385 | ///\r | |
386 | typedef struct {\r | |
387 | SPIN_LOCK *Msr;\r | |
388 | UINTN AvailableCounter;\r | |
389 | } SMM_CPU_SEMAPHORE_MSR;\r | |
4e920581 | 390 | \r |
1d648531 JF |
391 | ///\r |
392 | /// All semaphores' information\r | |
393 | ///\r | |
394 | typedef struct {\r | |
395 | SMM_CPU_SEMAPHORE_GLOBAL SemaphoreGlobal;\r | |
4e920581 | 396 | SMM_CPU_SEMAPHORE_CPU SemaphoreCpu;\r |
695e62d1 | 397 | SMM_CPU_SEMAPHORE_MSR SemaphoreMsr;\r |
1d648531 JF |
398 | } SMM_CPU_SEMAPHORES;\r |
399 | \r | |
529a5a86 | 400 | extern IA32_DESCRIPTOR gcSmiGdtr;\r |
717fb604 JY |
401 | extern EFI_PHYSICAL_ADDRESS mGdtBuffer;\r |
402 | extern UINTN mGdtBufferSize;\r | |
529a5a86 MK |
403 | extern IA32_DESCRIPTOR gcSmiIdtr;\r |
404 | extern VOID *gcSmiIdtrPtr;\r | |
529a5a86 | 405 | extern UINT64 gPhyMask;\r |
529a5a86 | 406 | extern SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData;\r |
529a5a86 MK |
407 | extern UINTN mSmmStackArrayBase;\r |
408 | extern UINTN mSmmStackArrayEnd;\r | |
409 | extern UINTN mSmmStackSize;\r | |
410 | extern EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService;\r | |
411 | extern IA32_DESCRIPTOR gcSmiInitGdtr;\r | |
dc99315b JF |
412 | extern SMM_CPU_SEMAPHORES mSmmCpuSemaphores;\r |
413 | extern UINTN mSemaphoreSize;\r | |
fe3a75bc JF |
414 | extern SPIN_LOCK *mPFLock;\r |
415 | extern SPIN_LOCK *mConfigSmmCodeAccessCheckLock;\r | |
6c4c15fa | 416 | extern SPIN_LOCK *mMemoryMappedLock;\r |
529a5a86 MK |
417 | \r |
418 | /**\r | |
419 | Create 4G PageTable in SMRAM.\r | |
420 | \r | |
717fb604 | 421 | @param[in] Is32BitPageTable Whether the page table is 32-bit PAE\r |
529a5a86 MK |
422 | @return PageTable Address\r |
423 | \r | |
424 | **/\r | |
425 | UINT32\r | |
426 | Gen4GPageTable (\r | |
881520ea | 427 | IN BOOLEAN Is32BitPageTable\r |
529a5a86 MK |
428 | );\r |
429 | \r | |
430 | \r | |
431 | /**\r | |
432 | Initialize global data for MP synchronization.\r | |
433 | \r | |
434 | @param Stacks Base address of SMI stack buffer for all processors.\r | |
435 | @param StackSize Stack size for each processor in SMM.\r | |
436 | \r | |
437 | **/\r | |
438 | UINT32\r | |
439 | InitializeMpServiceData (\r | |
440 | IN VOID *Stacks,\r | |
441 | IN UINTN StackSize\r | |
442 | );\r | |
443 | \r | |
444 | /**\r | |
445 | Initialize Timer for SMM AP Sync.\r | |
446 | \r | |
447 | **/\r | |
448 | VOID\r | |
449 | InitializeSmmTimer (\r | |
450 | VOID\r | |
451 | );\r | |
452 | \r | |
453 | /**\r | |
454 | Start Timer for SMM AP Sync.\r | |
455 | \r | |
456 | **/\r | |
457 | UINT64\r | |
458 | EFIAPI\r | |
459 | StartSyncTimer (\r | |
460 | VOID\r | |
461 | );\r | |
462 | \r | |
463 | /**\r | |
464 | Check if the SMM AP Sync timer is timeout.\r | |
465 | \r | |
466 | @param Timer The start timer from the begin.\r | |
467 | \r | |
468 | **/\r | |
469 | BOOLEAN\r | |
470 | EFIAPI\r | |
471 | IsSyncTimerTimeout (\r | |
472 | IN UINT64 Timer\r | |
473 | );\r | |
474 | \r | |
475 | /**\r | |
476 | Initialize IDT for SMM Stack Guard.\r | |
477 | \r | |
478 | **/\r | |
479 | VOID\r | |
480 | EFIAPI\r | |
481 | InitializeIDTSmmStackGuard (\r | |
482 | VOID\r | |
483 | );\r | |
484 | \r | |
fe5f1949 JY |
485 | /**\r |
486 | Initialize Gdt for all processors.\r | |
717fb604 | 487 | \r |
fe5f1949 JY |
488 | @param[in] Cr3 CR3 value.\r |
489 | @param[out] GdtStepSize The step size for GDT table.\r | |
490 | \r | |
491 | @return GdtBase for processor 0.\r | |
492 | GdtBase for processor X is: GdtBase + (GdtStepSize * X)\r | |
493 | **/\r | |
494 | VOID *\r | |
495 | InitGdt (\r | |
496 | IN UINTN Cr3,\r | |
497 | OUT UINTN *GdtStepSize\r | |
498 | );\r | |
499 | \r | |
e4435f71 JY |
500 | /**\r |
501 | This function sets GDT/IDT buffer to be RO and XP.\r | |
502 | **/\r | |
503 | VOID\r | |
504 | PatchGdtIdtMap (\r | |
505 | VOID\r | |
506 | );\r | |
507 | \r | |
529a5a86 MK |
508 | /**\r |
509 | \r | |
510 | Register the SMM Foundation entry point.\r | |
511 | \r | |
512 | @param This Pointer to EFI_SMM_CONFIGURATION_PROTOCOL instance\r | |
513 | @param SmmEntryPoint SMM Foundation EntryPoint\r | |
514 | \r | |
515 | @retval EFI_SUCCESS Successfully to register SMM foundation entry point\r | |
516 | \r | |
517 | **/\r | |
518 | EFI_STATUS\r | |
519 | EFIAPI\r | |
520 | RegisterSmmEntry (\r | |
521 | IN CONST EFI_SMM_CONFIGURATION_PROTOCOL *This,\r | |
522 | IN EFI_SMM_ENTRY_POINT SmmEntryPoint\r | |
523 | );\r | |
524 | \r | |
525 | /**\r | |
526 | Create PageTable for SMM use.\r | |
527 | \r | |
528 | @return PageTable Address\r | |
529 | \r | |
530 | **/\r | |
531 | UINT32\r | |
532 | SmmInitPageTable (\r | |
533 | VOID\r | |
534 | );\r | |
535 | \r | |
536 | /**\r | |
537 | Schedule a procedure to run on the specified CPU.\r | |
538 | \r | |
539 | @param Procedure The address of the procedure to run\r | |
540 | @param CpuIndex Target CPU number\r | |
541 | @param ProcArguments The parameter to pass to the procedure\r | |
542 | \r | |
543 | @retval EFI_INVALID_PARAMETER CpuNumber not valid\r | |
544 | @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP\r | |
545 | @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM\r | |
546 | @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy\r | |
547 | @retval EFI_SUCCESS - The procedure has been successfully scheduled\r | |
548 | \r | |
549 | **/\r | |
550 | EFI_STATUS\r | |
551 | EFIAPI\r | |
552 | SmmStartupThisAp (\r | |
553 | IN EFI_AP_PROCEDURE Procedure,\r | |
554 | IN UINTN CpuIndex,\r | |
555 | IN OUT VOID *ProcArguments OPTIONAL\r | |
556 | );\r | |
557 | \r | |
558 | /**\r | |
559 | Schedule a procedure to run on the specified CPU in a blocking fashion.\r | |
560 | \r | |
561 | @param Procedure The address of the procedure to run\r | |
562 | @param CpuIndex Target CPU Index\r | |
563 | @param ProcArguments The parameter to pass to the procedure\r | |
564 | \r | |
565 | @retval EFI_INVALID_PARAMETER CpuNumber not valid\r | |
566 | @retval EFI_INVALID_PARAMETER CpuNumber specifying BSP\r | |
567 | @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber did not enter SMM\r | |
568 | @retval EFI_INVALID_PARAMETER The AP specified by CpuNumber is busy\r | |
569 | @retval EFI_SUCCESS The procedure has been successfully scheduled\r | |
570 | \r | |
571 | **/\r | |
572 | EFI_STATUS\r | |
573 | EFIAPI\r | |
574 | SmmBlockingStartupThisAp (\r | |
575 | IN EFI_AP_PROCEDURE Procedure,\r | |
576 | IN UINTN CpuIndex,\r | |
577 | IN OUT VOID *ProcArguments OPTIONAL\r | |
578 | );\r | |
579 | \r | |
e4435f71 JY |
580 | /**\r |
581 | This function sets the attributes for the memory region specified by BaseAddress and\r | |
582 | Length from their current attributes to the attributes specified by Attributes.\r | |
583 | \r | |
584 | @param[in] BaseAddress The physical address that is the start address of a memory region.\r | |
585 | @param[in] Length The size in bytes of the memory region.\r | |
586 | @param[in] Attributes The bit mask of attributes to set for the memory region.\r | |
587 | \r | |
588 | @retval EFI_SUCCESS The attributes were set for the memory region.\r | |
589 | @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by\r | |
590 | BaseAddress and Length cannot be modified.\r | |
591 | @retval EFI_INVALID_PARAMETER Length is zero.\r | |
592 | Attributes specified an illegal combination of attributes that\r | |
593 | cannot be set together.\r | |
594 | @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of\r | |
595 | the memory resource range.\r | |
596 | @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory\r | |
597 | resource range specified by BaseAddress and Length.\r | |
598 | The bit mask of attributes is not support for the memory resource\r | |
599 | range specified by BaseAddress and Length.\r | |
600 | \r | |
601 | **/\r | |
602 | EFI_STATUS\r | |
603 | EFIAPI\r | |
604 | SmmSetMemoryAttributes (\r | |
605 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
606 | IN UINT64 Length,\r | |
607 | IN UINT64 Attributes\r | |
608 | );\r | |
609 | \r | |
610 | /**\r | |
611 | This function clears the attributes for the memory region specified by BaseAddress and\r | |
612 | Length from their current attributes to the attributes specified by Attributes.\r | |
613 | \r | |
614 | @param[in] BaseAddress The physical address that is the start address of a memory region.\r | |
615 | @param[in] Length The size in bytes of the memory region.\r | |
616 | @param[in] Attributes The bit mask of attributes to clear for the memory region.\r | |
617 | \r | |
618 | @retval EFI_SUCCESS The attributes were cleared for the memory region.\r | |
619 | @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by\r | |
620 | BaseAddress and Length cannot be modified.\r | |
621 | @retval EFI_INVALID_PARAMETER Length is zero.\r | |
622 | Attributes specified an illegal combination of attributes that\r | |
623 | cannot be set together.\r | |
624 | @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of\r | |
625 | the memory resource range.\r | |
626 | @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory\r | |
627 | resource range specified by BaseAddress and Length.\r | |
628 | The bit mask of attributes is not support for the memory resource\r | |
629 | range specified by BaseAddress and Length.\r | |
630 | \r | |
631 | **/\r | |
632 | EFI_STATUS\r | |
633 | EFIAPI\r | |
634 | SmmClearMemoryAttributes (\r | |
635 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
636 | IN UINT64 Length,\r | |
637 | IN UINT64 Attributes\r | |
638 | );\r | |
639 | \r | |
529a5a86 MK |
640 | /**\r |
641 | Initialize MP synchronization data.\r | |
642 | \r | |
643 | **/\r | |
644 | VOID\r | |
645 | EFIAPI\r | |
646 | InitializeMpSyncData (\r | |
647 | VOID\r | |
648 | );\r | |
649 | \r | |
650 | /**\r | |
651 | \r | |
652 | Find out SMRAM information including SMRR base and SMRR size.\r | |
653 | \r | |
654 | @param SmrrBase SMRR base\r | |
655 | @param SmrrSize SMRR size\r | |
656 | \r | |
657 | **/\r | |
658 | VOID\r | |
659 | FindSmramInfo (\r | |
660 | OUT UINT32 *SmrrBase,\r | |
661 | OUT UINT32 *SmrrSize\r | |
662 | );\r | |
663 | \r | |
664 | /**\r | |
0bdc9e75 | 665 | Relocate SmmBases for each processor.\r |
529a5a86 | 666 | \r |
0bdc9e75 | 667 | Execute on first boot and all S3 resumes\r |
529a5a86 MK |
668 | \r |
669 | **/\r | |
670 | VOID\r | |
0bdc9e75 SZ |
671 | EFIAPI\r |
672 | SmmRelocateBases (\r | |
529a5a86 MK |
673 | VOID\r |
674 | );\r | |
675 | \r | |
676 | /**\r | |
677 | Page Fault handler for SMM use.\r | |
678 | \r | |
679 | @param InterruptType Defines the type of interrupt or exception that\r | |
680 | occurred on the processor.This parameter is processor architecture specific.\r | |
681 | @param SystemContext A pointer to the processor context when\r | |
682 | the interrupt occurred on the processor.\r | |
683 | **/\r | |
684 | VOID\r | |
685 | EFIAPI\r | |
686 | SmiPFHandler (\r | |
687 | IN EFI_EXCEPTION_TYPE InterruptType,\r | |
688 | IN EFI_SYSTEM_CONTEXT SystemContext\r | |
689 | );\r | |
690 | \r | |
691 | /**\r | |
692 | Perform the remaining tasks.\r | |
693 | \r | |
694 | **/\r | |
695 | VOID\r | |
696 | PerformRemainingTasks (\r | |
697 | VOID\r | |
698 | );\r | |
699 | \r | |
9f419739 JY |
700 | /**\r |
701 | Perform the pre tasks.\r | |
702 | \r | |
703 | **/\r | |
704 | VOID\r | |
705 | PerformPreTasks (\r | |
706 | VOID\r | |
707 | );\r | |
708 | \r | |
529a5a86 MK |
709 | /**\r |
710 | Initialize MSR spin lock by MSR index.\r | |
711 | \r | |
712 | @param MsrIndex MSR index value.\r | |
713 | \r | |
714 | **/\r | |
715 | VOID\r | |
716 | InitMsrSpinLockByIndex (\r | |
717 | IN UINT32 MsrIndex\r | |
718 | );\r | |
719 | \r | |
720 | /**\r | |
721 | Hook return address of SMM Save State so that semaphore code\r | |
722 | can be executed immediately after AP exits SMM to indicate to\r | |
723 | the BSP that an AP has exited SMM after SMBASE relocation.\r | |
724 | \r | |
725 | @param[in] CpuIndex The processor index.\r | |
726 | @param[in] RebasedFlag A pointer to a flag that is set to TRUE\r | |
727 | immediately after AP exits SMM.\r | |
728 | \r | |
729 | **/\r | |
730 | VOID\r | |
731 | SemaphoreHook (\r | |
732 | IN UINTN CpuIndex,\r | |
733 | IN volatile BOOLEAN *RebasedFlag\r | |
734 | );\r | |
735 | \r | |
736 | /**\r | |
737 | Configure SMM Code Access Check feature for all processors.\r | |
738 | SMM Feature Control MSR will be locked after configuration.\r | |
739 | **/\r | |
740 | VOID\r | |
741 | ConfigSmmCodeAccessCheck (\r | |
742 | VOID\r | |
743 | );\r | |
744 | \r | |
745 | /**\r | |
746 | Hook the code executed immediately after an RSM instruction on the currently\r | |
747 | executing CPU. The mode of code executed immediately after RSM must be\r | |
748 | detected, and the appropriate hook must be selected. Always clear the auto\r | |
749 | HALT restart flag if it is set.\r | |
750 | \r | |
751 | @param[in] CpuIndex The processor index for the currently\r | |
752 | executing CPU.\r | |
753 | @param[in] CpuState Pointer to SMRAM Save State Map for the\r | |
754 | currently executing CPU.\r | |
755 | @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to\r | |
756 | 32-bit mode from 64-bit SMM.\r | |
757 | @param[in] NewInstructionPointer Instruction pointer to use if resuming to\r | |
758 | same mode as SMM.\r | |
759 | \r | |
760 | @retval The value of the original instruction pointer before it was hooked.\r | |
761 | \r | |
762 | **/\r | |
763 | UINT64\r | |
764 | EFIAPI\r | |
765 | HookReturnFromSmm (\r | |
766 | IN UINTN CpuIndex,\r | |
767 | SMRAM_SAVE_STATE_MAP *CpuState,\r | |
768 | UINT64 NewInstructionPointer32,\r | |
769 | UINT64 NewInstructionPointer\r | |
770 | );\r | |
771 | \r | |
772 | /**\r | |
773 | Get the size of the SMI Handler in bytes.\r | |
774 | \r | |
775 | @retval The size, in bytes, of the SMI Handler.\r | |
776 | \r | |
777 | **/\r | |
778 | UINTN\r | |
779 | EFIAPI\r | |
780 | GetSmiHandlerSize (\r | |
781 | VOID\r | |
782 | );\r | |
783 | \r | |
784 | /**\r | |
785 | Install the SMI handler for the CPU specified by CpuIndex. This function\r | |
786 | is called by the CPU that was elected as monarch during System Management\r | |
787 | Mode initialization.\r | |
788 | \r | |
789 | @param[in] CpuIndex The index of the CPU to install the custom SMI handler.\r | |
790 | The value must be between 0 and the NumberOfCpus field\r | |
791 | in the System Management System Table (SMST).\r | |
792 | @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex.\r | |
793 | @param[in] SmiStack The stack to use when an SMI is processed by the\r | |
794 | the CPU specified by CpuIndex.\r | |
795 | @param[in] StackSize The size, in bytes, if the stack used when an SMI is\r | |
796 | processed by the CPU specified by CpuIndex.\r | |
797 | @param[in] GdtBase The base address of the GDT to use when an SMI is\r | |
798 | processed by the CPU specified by CpuIndex.\r | |
799 | @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is\r | |
800 | processed by the CPU specified by CpuIndex.\r | |
801 | @param[in] IdtBase The base address of the IDT to use when an SMI is\r | |
802 | processed by the CPU specified by CpuIndex.\r | |
803 | @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is\r | |
804 | processed by the CPU specified by CpuIndex.\r | |
805 | @param[in] Cr3 The base address of the page tables to use when an SMI\r | |
806 | is processed by the CPU specified by CpuIndex.\r | |
807 | **/\r | |
808 | VOID\r | |
809 | EFIAPI\r | |
810 | InstallSmiHandler (\r | |
811 | IN UINTN CpuIndex,\r | |
812 | IN UINT32 SmBase,\r | |
813 | IN VOID *SmiStack,\r | |
814 | IN UINTN StackSize,\r | |
815 | IN UINTN GdtBase,\r | |
816 | IN UINTN GdtSize,\r | |
817 | IN UINTN IdtBase,\r | |
818 | IN UINTN IdtSize,\r | |
819 | IN UINT32 Cr3\r | |
820 | );\r | |
821 | \r | |
822 | /**\r | |
823 | Search module name by input IP address and output it.\r | |
824 | \r | |
825 | @param CallerIpAddress Caller instruction pointer.\r | |
826 | \r | |
827 | **/\r | |
828 | VOID\r | |
829 | DumpModuleInfoByIp (\r | |
830 | IN UINTN CallerIpAddress\r | |
831 | );\r | |
21c17193 | 832 | \r |
717fb604 JY |
833 | /**\r |
834 | This function sets memory attribute according to MemoryAttributesTable.\r | |
835 | **/\r | |
836 | VOID\r | |
837 | SetMemMapAttributes (\r | |
838 | VOID\r | |
839 | );\r | |
840 | \r | |
d2fc7711 JY |
841 | /**\r |
842 | This function sets UEFI memory attribute according to UEFI memory map.\r | |
843 | **/\r | |
844 | VOID\r | |
845 | SetUefiMemMapAttributes (\r | |
846 | VOID\r | |
847 | );\r | |
848 | \r | |
849 | /**\r | |
850 | Return if the Address is forbidden as SMM communication buffer.\r | |
851 | \r | |
852 | @param[in] Address the address to be checked\r | |
853 | \r | |
854 | @return TRUE The address is forbidden as SMM communication buffer.\r | |
855 | @return FALSE The address is allowed as SMM communication buffer.\r | |
856 | **/\r | |
857 | BOOLEAN\r | |
858 | IsSmmCommBufferForbiddenAddress (\r | |
859 | IN UINT64 Address\r | |
860 | );\r | |
861 | \r | |
862 | /**\r | |
863 | This function caches the UEFI memory map information.\r | |
864 | **/\r | |
865 | VOID\r | |
866 | GetUefiMemoryMap (\r | |
867 | VOID\r | |
868 | );\r | |
869 | \r | |
717fb604 JY |
870 | /**\r |
871 | This function sets memory attribute for page table.\r | |
872 | **/\r | |
873 | VOID\r | |
874 | SetPageTableAttributes (\r | |
875 | VOID\r | |
876 | );\r | |
877 | \r | |
878 | /**\r | |
879 | Return page table base.\r | |
880 | \r | |
881 | @return page table base.\r | |
882 | **/\r | |
883 | UINTN\r | |
884 | GetPageTableBase (\r | |
885 | VOID\r | |
886 | );\r | |
887 | \r | |
888 | /**\r | |
889 | This function sets the attributes for the memory region specified by BaseAddress and\r | |
890 | Length from their current attributes to the attributes specified by Attributes.\r | |
891 | \r | |
892 | @param[in] BaseAddress The physical address that is the start address of a memory region.\r | |
893 | @param[in] Length The size in bytes of the memory region.\r | |
894 | @param[in] Attributes The bit mask of attributes to set for the memory region.\r | |
895 | @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted.\r | |
896 | \r | |
897 | @retval EFI_SUCCESS The attributes were set for the memory region.\r | |
898 | @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by\r | |
899 | BaseAddress and Length cannot be modified.\r | |
900 | @retval EFI_INVALID_PARAMETER Length is zero.\r | |
901 | Attributes specified an illegal combination of attributes that\r | |
902 | cannot be set together.\r | |
903 | @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of\r | |
904 | the memory resource range.\r | |
905 | @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory\r | |
906 | resource range specified by BaseAddress and Length.\r | |
907 | The bit mask of attributes is not support for the memory resource\r | |
908 | range specified by BaseAddress and Length.\r | |
909 | \r | |
910 | **/\r | |
911 | EFI_STATUS\r | |
912 | EFIAPI\r | |
913 | SmmSetMemoryAttributesEx (\r | |
914 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
915 | IN UINT64 Length,\r | |
916 | IN UINT64 Attributes,\r | |
917 | OUT BOOLEAN *IsSplitted OPTIONAL\r | |
918 | );\r | |
919 | \r | |
920 | /**\r | |
921 | This function clears the attributes for the memory region specified by BaseAddress and\r | |
922 | Length from their current attributes to the attributes specified by Attributes.\r | |
923 | \r | |
924 | @param[in] BaseAddress The physical address that is the start address of a memory region.\r | |
925 | @param[in] Length The size in bytes of the memory region.\r | |
926 | @param[in] Attributes The bit mask of attributes to clear for the memory region.\r | |
927 | @param[out] IsSplitted TRUE means page table splitted. FALSE means page table not splitted.\r | |
928 | \r | |
929 | @retval EFI_SUCCESS The attributes were cleared for the memory region.\r | |
930 | @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by\r | |
931 | BaseAddress and Length cannot be modified.\r | |
932 | @retval EFI_INVALID_PARAMETER Length is zero.\r | |
933 | Attributes specified an illegal combination of attributes that\r | |
934 | cannot be set together.\r | |
935 | @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of\r | |
936 | the memory resource range.\r | |
937 | @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory\r | |
938 | resource range specified by BaseAddress and Length.\r | |
939 | The bit mask of attributes is not support for the memory resource\r | |
940 | range specified by BaseAddress and Length.\r | |
941 | \r | |
942 | **/\r | |
943 | EFI_STATUS\r | |
944 | EFIAPI\r | |
945 | SmmClearMemoryAttributesEx (\r | |
946 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
947 | IN UINT64 Length,\r | |
948 | IN UINT64 Attributes,\r | |
949 | OUT BOOLEAN *IsSplitted OPTIONAL\r | |
950 | );\r | |
951 | \r | |
21c17193 JY |
952 | /**\r |
953 | This API provides a way to allocate memory for page table.\r | |
954 | \r | |
955 | This API can be called more once to allocate memory for page tables.\r | |
956 | \r | |
957 | Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r | |
958 | allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL\r | |
959 | is returned. If there is not enough memory remaining to satisfy the request, then NULL is\r | |
960 | returned.\r | |
961 | \r | |
962 | @param Pages The number of 4 KB pages to allocate.\r | |
963 | \r | |
964 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
965 | \r | |
966 | **/\r | |
967 | VOID *\r | |
968 | AllocatePageTableMemory (\r | |
969 | IN UINTN Pages\r | |
970 | );\r | |
971 | \r | |
717fb604 JY |
972 | /**\r |
973 | Allocate pages for code.\r | |
974 | \r | |
975 | @param[in] Pages Number of pages to be allocated.\r | |
976 | \r | |
977 | @return Allocated memory.\r | |
978 | **/\r | |
979 | VOID *\r | |
980 | AllocateCodePages (\r | |
981 | IN UINTN Pages\r | |
982 | );\r | |
983 | \r | |
984 | /**\r | |
985 | Allocate aligned pages for code.\r | |
986 | \r | |
987 | @param[in] Pages Number of pages to be allocated.\r | |
988 | @param[in] Alignment The requested alignment of the allocation.\r | |
989 | Must be a power of two.\r | |
990 | If Alignment is zero, then byte alignment is used.\r | |
991 | \r | |
992 | @return Allocated memory.\r | |
993 | **/\r | |
994 | VOID *\r | |
995 | AllocateAlignedCodePages (\r | |
996 | IN UINTN Pages,\r | |
997 | IN UINTN Alignment\r | |
998 | );\r | |
999 | \r | |
0bdc9e75 SZ |
1000 | \r |
1001 | //\r | |
1002 | // S3 related global variable and function prototype.\r | |
1003 | //\r | |
1004 | \r | |
1005 | extern BOOLEAN mSmmS3Flag;\r | |
1006 | \r | |
1007 | /**\r | |
1008 | Initialize SMM S3 resume state structure used during S3 Resume.\r | |
1009 | \r | |
1010 | @param[in] Cr3 The base address of the page tables to use in SMM.\r | |
1011 | \r | |
1012 | **/\r | |
1013 | VOID\r | |
1014 | InitSmmS3ResumeState (\r | |
1015 | IN UINT32 Cr3\r | |
1016 | );\r | |
1017 | \r | |
1018 | /**\r | |
1019 | Get ACPI CPU data.\r | |
1020 | \r | |
1021 | **/\r | |
1022 | VOID\r | |
1023 | GetAcpiCpuData (\r | |
1024 | VOID\r | |
1025 | );\r | |
1026 | \r | |
1027 | /**\r | |
1028 | Restore SMM Configuration in S3 boot path.\r | |
1029 | \r | |
1030 | **/\r | |
1031 | VOID\r | |
1032 | RestoreSmmConfigurationInS3 (\r | |
1033 | VOID\r | |
1034 | );\r | |
1035 | \r | |
b10d5ddc SZ |
1036 | /**\r |
1037 | Get ACPI S3 enable flag.\r | |
1038 | \r | |
1039 | **/\r | |
1040 | VOID\r | |
1041 | GetAcpiS3EnableFlag (\r | |
1042 | VOID\r | |
1043 | );\r | |
1044 | \r | |
4a0f88dd JF |
1045 | /**\r |
1046 | Transfer AP to safe hlt-loop after it finished restore CPU features on S3 patch.\r | |
1047 | \r | |
672b80c8 MK |
1048 | @param[in] ApHltLoopCode The address of the safe hlt-loop function.\r |
1049 | @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode.\r | |
1050 | @param[in] NumberToFinishAddress Address of Semaphore of APs finish count.\r | |
4a0f88dd JF |
1051 | \r |
1052 | **/\r | |
1053 | VOID\r | |
1054 | TransferApToSafeState (\r | |
672b80c8 MK |
1055 | IN UINTN ApHltLoopCode,\r |
1056 | IN UINTN TopOfStack,\r | |
1057 | IN UINTN NumberToFinishAddress\r | |
4a0f88dd JF |
1058 | );\r |
1059 | \r | |
529a5a86 | 1060 | #endif\r |