]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c
Use CPU_HOB to detect max address support from platform, and added 1G page table...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / Acpi / AcpiS3SaveDxe / AcpiS3Save.c
CommitLineData
13d4af68 1/** @file\r
2 This is an implementation of the ACPI S3 Save protocol. This is defined in\r
3 S3 boot path specification 0.9.\r
4\r
5Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
6\r
7This program and the accompanying materials\r
8are licensed and made available under the terms and conditions\r
9of the BSD License which accompanies this distribution. The\r
10full text of the license may be found at\r
11http://opensource.org/licenses/bsd-license.php\r
12\r
13THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#include <PiDxe.h>\r
19#include <Library/BaseLib.h>\r
20#include <Library/BaseMemoryLib.h>\r
21#include <Library/UefiBootServicesTableLib.h>\r
22#include <Library/UefiRuntimeServicesTableLib.h>\r
c56b6566 23#include <Library/HobLib.h>\r
13d4af68 24#include <Library/LockBoxLib.h>\r
25#include <Library/PcdLib.h>\r
26#include <Library/DebugLib.h>\r
27#include <Guid/AcpiVariableCompatibility.h>\r
28#include <Guid/AcpiS3Context.h>\r
29#include <Guid/Acpi.h>\r
30#include <Protocol/AcpiS3Save.h>\r
31#include <IndustryStandard/Acpi.h>\r
32\r
33#include "AcpiS3Save.h"\r
34\r
35/**\r
36 Hook point for AcpiVariableThunkPlatform for InstallAcpiS3Save.\r
37**/\r
38VOID\r
39InstallAcpiS3SaveThunk (\r
40 VOID\r
41 );\r
42\r
43/**\r
44 Hook point for AcpiVariableThunkPlatform for S3Ready.\r
45\r
46 @param AcpiS3Context ACPI s3 context\r
47**/\r
48VOID\r
49S3ReadyThunkPlatform (\r
50 IN ACPI_S3_CONTEXT *AcpiS3Context\r
51 );\r
52\r
53UINTN mLegacyRegionSize;\r
54\r
55EFI_ACPI_S3_SAVE_PROTOCOL mS3Save = {\r
56 LegacyGetS3MemorySize,\r
57 S3Ready,\r
58};\r
59\r
60EFI_GUID mAcpiS3IdtrProfileGuid = {\r
61 0xdea652b0, 0xd587, 0x4c54, 0xb5, 0xb4, 0xc6, 0x82, 0xe7, 0xa0, 0xaa, 0x3d\r
62};\r
63\r
64/**\r
65 Allocate EfiACPIMemoryNVS below 4G memory address.\r
66\r
67 This function allocates EfiACPIMemoryNVS below 4G memory address.\r
68\r
69 @param Size Size of memory to allocate.\r
70 \r
71 @return Allocated address for output.\r
72\r
73**/\r
74VOID*\r
75AllocateAcpiNvsMemoryBelow4G (\r
76 IN UINTN Size\r
77 )\r
78{\r
79 UINTN Pages;\r
80 EFI_PHYSICAL_ADDRESS Address;\r
81 EFI_STATUS Status;\r
82 VOID* Buffer;\r
83\r
84 Pages = EFI_SIZE_TO_PAGES (Size);\r
85 Address = 0xffffffff;\r
86\r
87 Status = gBS->AllocatePages (\r
88 AllocateMaxAddress,\r
89 EfiACPIMemoryNVS,\r
90 Pages,\r
91 &Address\r
92 );\r
93 ASSERT_EFI_ERROR (Status);\r
94\r
95 Buffer = (VOID *) (UINTN) Address;\r
96 ZeroMem (Buffer, Size);\r
97\r
98 return Buffer;\r
99}\r
100\r
101/**\r
102 To find Facs in Acpi tables.\r
103 \r
104 To find Firmware ACPI control strutcure in Acpi Tables since the S3 waking vector is stored \r
105 in the table.\r
106\r
107 @param AcpiTableGuid The guid used to find ACPI table in UEFI ConfigurationTable.\r
108 \r
109 @return Facs table pointer.\r
110**/\r
111EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *\r
112FindAcpiFacsTableByAcpiGuid (\r
113 IN EFI_GUID *AcpiTableGuid\r
114 )\r
115{\r
116 EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;\r
117 EFI_ACPI_DESCRIPTION_HEADER *Rsdt;\r
118 EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;\r
119 EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs;\r
120 UINTN Index;\r
121 UINT32 Data32;\r
122 Rsdp = NULL;\r
123 Rsdt = NULL;\r
124 Fadt = NULL;\r
125 //\r
126 // found ACPI table RSD_PTR from system table\r
127 //\r
128 for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r
129 if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), AcpiTableGuid)) {\r
130 //\r
131 // A match was found.\r
132 //\r
133 Rsdp = gST->ConfigurationTable[Index].VendorTable;\r
134 break;\r
135 }\r
136 }\r
137\r
138 if (Rsdp == NULL) {\r
139 return NULL;\r
140 }\r
141\r
142 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->RsdtAddress;\r
143 if (Rsdt == NULL || Rsdt->Signature != EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {\r
144 return NULL;\r
145 }\r
146\r
147 for (Index = sizeof (EFI_ACPI_DESCRIPTION_HEADER); Index < Rsdt->Length; Index = Index + sizeof (UINT32)) {\r
148\r
149 Data32 = *(UINT32 *) ((UINT8 *) Rsdt + Index);\r
150 Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) (UINT32 *) (UINTN) Data32;\r
151 if (Fadt->Header.Signature == EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {\r
152 break;\r
153 }\r
154 }\r
155\r
156 if (Fadt == NULL || Fadt->Header.Signature != EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {\r
157 return NULL;\r
158 }\r
159\r
160 Facs = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)Fadt->FirmwareCtrl;\r
161\r
162 return Facs;\r
163}\r
164\r
165/**\r
166 To find Facs in Acpi tables.\r
167 \r
168 To find Firmware ACPI control strutcure in Acpi Tables since the S3 waking vector is stored \r
169 in the table.\r
170 \r
171 @return Facs table pointer.\r
172**/\r
173EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *\r
174FindAcpiFacsTable (\r
175 VOID\r
176 )\r
177{\r
178 EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs;\r
179\r
180 Facs = FindAcpiFacsTableByAcpiGuid (&gEfiAcpi20TableGuid);\r
181 if (Facs != NULL) {\r
182 return Facs;\r
183 }\r
184\r
185 return FindAcpiFacsTableByAcpiGuid (&gEfiAcpi10TableGuid);\r
186}\r
187\r
188/**\r
189 Allocates and fills in the Page Directory and Page Table Entries to\r
190 establish a 1:1 Virtual to Physical mapping.\r
191 If BootScriptExector driver will run in 64-bit mode, this function will establish the 1:1 \r
192 virtual to physical mapping page table.\r
193 If BootScriptExector driver will not run in 64-bit mode, this function will do nothing. \r
194 \r
195 @return the 1:1 Virtual to Physical identity mapping page table base address. \r
196\r
197**/\r
198EFI_PHYSICAL_ADDRESS\r
199S3CreateIdentityMappingPageTables (\r
200 VOID\r
201 )\r
202{ \r
203 if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {\r
204 UINT32 RegEax;\r
c56b6566 205 UINT32 RegEdx;\r
13d4af68 206 UINT8 PhysicalAddressBits;\r
207 EFI_PHYSICAL_ADDRESS PageAddress;\r
208 UINTN IndexOfPml4Entries;\r
209 UINTN IndexOfPdpEntries;\r
210 UINTN IndexOfPageDirectoryEntries;\r
c56b6566
JY
211 UINT32 NumberOfPml4EntriesNeeded;\r
212 UINT32 NumberOfPdpEntriesNeeded;\r
13d4af68 213 PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry;\r
214 PAGE_MAP_AND_DIRECTORY_POINTER *PageMap;\r
215 PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;\r
216 PAGE_TABLE_ENTRY *PageDirectoryEntry;\r
217 EFI_PHYSICAL_ADDRESS S3NvsPageTableAddress;\r
218 UINTN TotalPageTableSize;\r
c56b6566
JY
219 VOID *Hob;\r
220 BOOLEAN Page1GSupport;\r
221 PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry;\r
222\r
223 Page1GSupport = FALSE;\r
224 AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);\r
225 if (RegEax >= 0x80000001) {\r
226 AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx);\r
227 if ((RegEdx & BIT26) != 0) {\r
228 Page1GSupport = TRUE;\r
229 }\r
230 }\r
13d4af68 231\r
232 //\r
233 // Get physical address bits supported.\r
234 //\r
c56b6566
JY
235 Hob = GetFirstHob (EFI_HOB_TYPE_CPU);\r
236 if (Hob != NULL) {\r
237 PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace;\r
13d4af68 238 } else {\r
c56b6566
JY
239 AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);\r
240 if (RegEax >= 0x80000008) {\r
241 AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);\r
242 PhysicalAddressBits = (UINT8) RegEax;\r
243 } else {\r
244 PhysicalAddressBits = 36;\r
245 }\r
13d4af68 246 }\r
247 \r
c56b6566
JY
248 //\r
249 // IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses.\r
250 //\r
251 ASSERT (PhysicalAddressBits <= 52);\r
252 if (PhysicalAddressBits > 48) {\r
253 PhysicalAddressBits = 48;\r
254 }\r
255\r
13d4af68 256 //\r
257 // Calculate the table entries needed.\r
258 //\r
259 if (PhysicalAddressBits <= 39 ) {\r
260 NumberOfPml4EntriesNeeded = 1;\r
c56b6566 261 NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30));\r
13d4af68 262 } else {\r
c56b6566 263 NumberOfPml4EntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 39));\r
13d4af68 264 NumberOfPdpEntriesNeeded = 512;\r
265 }\r
266\r
267 //\r
268 // We need calculate whole page size then allocate once, because S3 restore page table does not know each page in Nvs.\r
269 //\r
c56b6566
JY
270 if (!Page1GSupport) {\r
271 TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded + NumberOfPml4EntriesNeeded * NumberOfPdpEntriesNeeded);\r
272 } else {\r
273 TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded);\r
274 }\r
13d4af68 275 DEBUG ((EFI_D_ERROR, "TotalPageTableSize - %x pages\n", TotalPageTableSize));\r
276\r
277 //\r
278 // By architecture only one PageMapLevel4 exists - so lets allocate storgage for it.\r
279 //\r
280 S3NvsPageTableAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateAcpiNvsMemoryBelow4G (EFI_PAGES_TO_SIZE(TotalPageTableSize));\r
281 ASSERT (S3NvsPageTableAddress != 0);\r
282 PageMap = (PAGE_MAP_AND_DIRECTORY_POINTER *)(UINTN)S3NvsPageTableAddress;\r
283 S3NvsPageTableAddress += SIZE_4KB;\r
284\r
285 PageMapLevel4Entry = PageMap;\r
286 PageAddress = 0;\r
287 for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) {\r
288 //\r
289 // Each PML4 entry points to a page of Page Directory Pointer entires.\r
290 // So lets allocate space for them and fill them in in the IndexOfPdpEntries loop.\r
291 //\r
292 PageDirectoryPointerEntry = (PAGE_MAP_AND_DIRECTORY_POINTER *)(UINTN)S3NvsPageTableAddress;\r
293 S3NvsPageTableAddress += SIZE_4KB;\r
294 //\r
295 // Make a PML4 Entry\r
296 //\r
297 PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)PageDirectoryPointerEntry;\r
298 PageMapLevel4Entry->Bits.ReadWrite = 1;\r
299 PageMapLevel4Entry->Bits.Present = 1;\r
300 \r
c56b6566
JY
301 if (Page1GSupport) {\r
302 PageDirectory1GEntry = (VOID *) S3NvsPageTableAddress;\r
13d4af68 303 S3NvsPageTableAddress += SIZE_4KB;\r
304 \r
c56b6566 305 for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) {\r
13d4af68 306 //\r
307 // Fill in the Page Directory entries\r
308 //\r
c56b6566
JY
309 PageDirectory1GEntry->Uint64 = (UINT64)PageAddress;\r
310 PageDirectory1GEntry->Bits.ReadWrite = 1;\r
311 PageDirectory1GEntry->Bits.Present = 1;\r
312 PageDirectory1GEntry->Bits.MustBe1 = 1;\r
313 }\r
314 } else {\r
315 for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {\r
316 //\r
317 // Each Directory Pointer entries points to a page of Page Directory entires.\r
318 // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.\r
319 // \r
320 PageDirectoryEntry = (PAGE_TABLE_ENTRY *)(UINTN)S3NvsPageTableAddress;\r
321 S3NvsPageTableAddress += SIZE_4KB;\r
322 \r
323 //\r
324 // Fill in a Page Directory Pointer Entries\r
325 //\r
326 PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry;\r
327 PageDirectoryPointerEntry->Bits.ReadWrite = 1;\r
328 PageDirectoryPointerEntry->Bits.Present = 1;\r
329 \r
330 for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += SIZE_2MB) {\r
331 //\r
332 // Fill in the Page Directory entries\r
333 //\r
334 PageDirectoryEntry->Uint64 = (UINT64)PageAddress;\r
335 PageDirectoryEntry->Bits.ReadWrite = 1;\r
336 PageDirectoryEntry->Bits.Present = 1;\r
337 PageDirectoryEntry->Bits.MustBe1 = 1;\r
338 }\r
13d4af68 339 }\r
340 }\r
341 }\r
342 return (EFI_PHYSICAL_ADDRESS) (UINTN) PageMap;\r
343 } else {\r
344 //\r
345 // If DXE is running 32-bit mode, no need to establish page table.\r
346 //\r
347 return (EFI_PHYSICAL_ADDRESS) 0; \r
348 }\r
349}\r
350\r
351/**\r
352 Gets the buffer of legacy memory below 1 MB \r
353 This function is to get the buffer in legacy memory below 1MB that is required during S3 resume.\r
354\r
355 @param This A pointer to the EFI_ACPI_S3_SAVE_PROTOCOL instance.\r
356 @param Size The returned size of legacy memory below 1 MB.\r
357\r
358 @retval EFI_SUCCESS Size is successfully returned.\r
359 @retval EFI_INVALID_PARAMETER The pointer Size is NULL.\r
360\r
361**/\r
362EFI_STATUS\r
363EFIAPI\r
364LegacyGetS3MemorySize (\r
365 IN EFI_ACPI_S3_SAVE_PROTOCOL *This,\r
366 OUT UINTN *Size\r
367 )\r
368{\r
369 if (Size == NULL) {\r
370 return EFI_INVALID_PARAMETER;\r
371 }\r
372\r
373 *Size = mLegacyRegionSize;\r
374 return EFI_SUCCESS;\r
375}\r
376\r
377/**\r
378 Prepares all information that is needed in the S3 resume boot path.\r
379 \r
380 Allocate the resources or prepare informations and save in ACPI variable set for S3 resume boot path \r
381 \r
382 @param This A pointer to the EFI_ACPI_S3_SAVE_PROTOCOL instance.\r
383 @param LegacyMemoryAddress The base address of legacy memory.\r
384\r
385 @retval EFI_NOT_FOUND Some necessary information cannot be found.\r
386 @retval EFI_SUCCESS All information was saved successfully.\r
387 @retval EFI_OUT_OF_RESOURCES Resources were insufficient to save all the information.\r
388 @retval EFI_INVALID_PARAMETER The memory range is not located below 1 MB.\r
389\r
390**/\r
391EFI_STATUS\r
392EFIAPI\r
393S3Ready (\r
394 IN EFI_ACPI_S3_SAVE_PROTOCOL *This,\r
395 IN VOID *LegacyMemoryAddress\r
396 )\r
397{\r
398 EFI_STATUS Status;\r
399 EFI_PHYSICAL_ADDRESS AcpiS3ContextBuffer;\r
400 ACPI_S3_CONTEXT *AcpiS3Context;\r
401 STATIC BOOLEAN AlreadyEntered;\r
402 IA32_DESCRIPTOR *Idtr;\r
403 IA32_IDT_GATE_DESCRIPTOR *IdtGate;\r
404\r
405 DEBUG ((EFI_D_INFO, "S3Ready!\n"));\r
406\r
407 //\r
408 // Platform may invoke AcpiS3Save->S3Save() before ExitPmAuth, because we need save S3 information there, while BDS ReadyToBoot may invoke it again.\r
409 // So if 2nd S3Save() is triggered later, we need ignore it.\r
410 //\r
411 if (AlreadyEntered) {\r
412 return EFI_SUCCESS;\r
413 }\r
414 AlreadyEntered = TRUE;\r
415\r
416 AcpiS3Context = AllocateAcpiNvsMemoryBelow4G (sizeof(*AcpiS3Context));\r
417 ASSERT (AcpiS3Context != NULL);\r
418 AcpiS3ContextBuffer = (EFI_PHYSICAL_ADDRESS)(UINTN)AcpiS3Context;\r
419\r
420 //\r
421 // Get ACPI Table because we will save its position to variable\r
422 //\r
423 AcpiS3Context->AcpiFacsTable = (EFI_PHYSICAL_ADDRESS)(UINTN)FindAcpiFacsTable ();\r
424 ASSERT (AcpiS3Context->AcpiFacsTable != 0);\r
425\r
426 IdtGate = AllocateAcpiNvsMemoryBelow4G (sizeof(IA32_IDT_GATE_DESCRIPTOR) * 0x100 + sizeof(IA32_DESCRIPTOR));\r
427 Idtr = (IA32_DESCRIPTOR *)(IdtGate + 0x100);\r
428 Idtr->Base = (UINTN)IdtGate;\r
429 Idtr->Limit = (UINT16)(sizeof(IA32_IDT_GATE_DESCRIPTOR) * 0x100 - 1);\r
430 AcpiS3Context->IdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)Idtr;\r
431\r
432 Status = SaveLockBox (\r
433 &mAcpiS3IdtrProfileGuid,\r
434 (VOID *)(UINTN)Idtr,\r
435 (UINTN)sizeof(IA32_DESCRIPTOR)\r
436 );\r
437 ASSERT_EFI_ERROR (Status);\r
438\r
439 Status = SetLockBoxAttributes (&mAcpiS3IdtrProfileGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);\r
440 ASSERT_EFI_ERROR (Status);\r
441\r
442 //\r
443 // Allocate page table\r
444 //\r
445 AcpiS3Context->S3NvsPageTableAddress = S3CreateIdentityMappingPageTables ();\r
446\r
447 //\r
448 // Allocate stack\r
449 //\r
450 AcpiS3Context->BootScriptStackSize = PcdGet32 (PcdS3BootScriptStackSize);\r
451 AcpiS3Context->BootScriptStackBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateAcpiNvsMemoryBelow4G (PcdGet32 (PcdS3BootScriptStackSize));\r
452 ASSERT (AcpiS3Context->BootScriptStackBase != 0);\r
453\r
454 //\r
455 // Allocate a code buffer < 4G for S3 debug to load external code\r
456 //\r
457 AcpiS3Context->S3DebugBufferAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateAcpiNvsMemoryBelow4G (EFI_PAGE_SIZE);\r
458\r
459 DEBUG((EFI_D_INFO, "AcpiS3Context: AcpiFacsTable is 0x%8x\n", AcpiS3Context->AcpiFacsTable));\r
460 DEBUG((EFI_D_INFO, "AcpiS3Context: IdtrProfile is 0x%8x\n", AcpiS3Context->IdtrProfile));\r
461 DEBUG((EFI_D_INFO, "AcpiS3Context: S3NvsPageTableAddress is 0x%8x\n", AcpiS3Context->S3NvsPageTableAddress));\r
462 DEBUG((EFI_D_INFO, "AcpiS3Context: S3DebugBufferAddress is 0x%8x\n", AcpiS3Context->S3DebugBufferAddress));\r
463\r
464 Status = SaveLockBox (\r
465 &gEfiAcpiVariableGuid,\r
466 &AcpiS3ContextBuffer,\r
467 sizeof(AcpiS3ContextBuffer)\r
468 );\r
469 ASSERT_EFI_ERROR (Status);\r
470\r
471 Status = SaveLockBox (\r
472 &gEfiAcpiS3ContextGuid,\r
473 (VOID *)(UINTN)AcpiS3Context,\r
474 (UINTN)sizeof(*AcpiS3Context)\r
475 );\r
476 ASSERT_EFI_ERROR (Status);\r
477\r
478 Status = SetLockBoxAttributes (&gEfiAcpiS3ContextGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);\r
479 ASSERT_EFI_ERROR (Status);\r
480\r
481 if (FeaturePcdGet(PcdFrameworkCompatibilitySupport)) {\r
482 S3ReadyThunkPlatform (AcpiS3Context);\r
483 }\r
484\r
485 return EFI_SUCCESS;\r
486}\r
487\r
488/**\r
489 The Driver Entry Point.\r
490 \r
491 The function is the driver Entry point which will produce AcpiS3SaveProtocol.\r
492 \r
493 @param ImageHandle A handle for the image that is initializing this driver\r
494 @param SystemTable A pointer to the EFI system table\r
495\r
496 @retval EFI_SUCCESS: Driver initialized successfully\r
497 @retval EFI_LOAD_ERROR: Failed to Initialize or has been loaded\r
498 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources\r
499\r
500**/\r
501EFI_STATUS\r
502EFIAPI\r
503InstallAcpiS3Save (\r
504 IN EFI_HANDLE ImageHandle,\r
505 IN EFI_SYSTEM_TABLE *SystemTable\r
506 )\r
507{\r
508 EFI_STATUS Status;\r
509\r
510 if (!FeaturePcdGet(PcdPlatformCsmSupport)) {\r
511 //\r
512 // More memory for no CSM tip, because GDT need relocation\r
513 //\r
514 mLegacyRegionSize = 0x250;\r
515 } else {\r
516 mLegacyRegionSize = 0x100;\r
517 }\r
518\r
519 if (FeaturePcdGet(PcdFrameworkCompatibilitySupport)) {\r
520 InstallAcpiS3SaveThunk ();\r
521 }\r
522\r
523 Status = gBS->InstallProtocolInterface (\r
524 &ImageHandle,\r
525 &gEfiAcpiS3SaveProtocolGuid,\r
526 EFI_NATIVE_INTERFACE,\r
527 &mS3Save\r
528 );\r
529 ASSERT_EFI_ERROR (Status);\r
530 return Status;\r
531}\r