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