]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c
Correct 1G page table generation.
[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 301 if (Page1GSupport) {\r
54d3b84e 302 PageDirectory1GEntry = (PAGE_TABLE_1G_ENTRY *)(UINTN)PageDirectoryPointerEntry;\r
13d4af68 303 \r
c56b6566 304 for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) {\r
13d4af68 305 //\r
306 // Fill in the Page Directory entries\r
307 //\r
c56b6566
JY
308 PageDirectory1GEntry->Uint64 = (UINT64)PageAddress;\r
309 PageDirectory1GEntry->Bits.ReadWrite = 1;\r
310 PageDirectory1GEntry->Bits.Present = 1;\r
311 PageDirectory1GEntry->Bits.MustBe1 = 1;\r
312 }\r
313 } else {\r
314 for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {\r
315 //\r
316 // Each Directory Pointer entries points to a page of Page Directory entires.\r
317 // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.\r
318 // \r
319 PageDirectoryEntry = (PAGE_TABLE_ENTRY *)(UINTN)S3NvsPageTableAddress;\r
320 S3NvsPageTableAddress += SIZE_4KB;\r
321 \r
322 //\r
323 // Fill in a Page Directory Pointer Entries\r
324 //\r
325 PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry;\r
326 PageDirectoryPointerEntry->Bits.ReadWrite = 1;\r
327 PageDirectoryPointerEntry->Bits.Present = 1;\r
328 \r
329 for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += SIZE_2MB) {\r
330 //\r
331 // Fill in the Page Directory entries\r
332 //\r
333 PageDirectoryEntry->Uint64 = (UINT64)PageAddress;\r
334 PageDirectoryEntry->Bits.ReadWrite = 1;\r
335 PageDirectoryEntry->Bits.Present = 1;\r
336 PageDirectoryEntry->Bits.MustBe1 = 1;\r
337 }\r
13d4af68 338 }\r
339 }\r
340 }\r
341 return (EFI_PHYSICAL_ADDRESS) (UINTN) PageMap;\r
342 } else {\r
343 //\r
344 // If DXE is running 32-bit mode, no need to establish page table.\r
345 //\r
346 return (EFI_PHYSICAL_ADDRESS) 0; \r
347 }\r
348}\r
349\r
350/**\r
351 Gets the buffer of legacy memory below 1 MB \r
352 This function is to get the buffer in legacy memory below 1MB that is required during S3 resume.\r
353\r
354 @param This A pointer to the EFI_ACPI_S3_SAVE_PROTOCOL instance.\r
355 @param Size The returned size of legacy memory below 1 MB.\r
356\r
357 @retval EFI_SUCCESS Size is successfully returned.\r
358 @retval EFI_INVALID_PARAMETER The pointer Size is NULL.\r
359\r
360**/\r
361EFI_STATUS\r
362EFIAPI\r
363LegacyGetS3MemorySize (\r
364 IN EFI_ACPI_S3_SAVE_PROTOCOL *This,\r
365 OUT UINTN *Size\r
366 )\r
367{\r
368 if (Size == NULL) {\r
369 return EFI_INVALID_PARAMETER;\r
370 }\r
371\r
372 *Size = mLegacyRegionSize;\r
373 return EFI_SUCCESS;\r
374}\r
375\r
376/**\r
377 Prepares all information that is needed in the S3 resume boot path.\r
378 \r
379 Allocate the resources or prepare informations and save in ACPI variable set for S3 resume boot path \r
380 \r
381 @param This A pointer to the EFI_ACPI_S3_SAVE_PROTOCOL instance.\r
382 @param LegacyMemoryAddress The base address of legacy memory.\r
383\r
384 @retval EFI_NOT_FOUND Some necessary information cannot be found.\r
385 @retval EFI_SUCCESS All information was saved successfully.\r
386 @retval EFI_OUT_OF_RESOURCES Resources were insufficient to save all the information.\r
387 @retval EFI_INVALID_PARAMETER The memory range is not located below 1 MB.\r
388\r
389**/\r
390EFI_STATUS\r
391EFIAPI\r
392S3Ready (\r
393 IN EFI_ACPI_S3_SAVE_PROTOCOL *This,\r
394 IN VOID *LegacyMemoryAddress\r
395 )\r
396{\r
397 EFI_STATUS Status;\r
398 EFI_PHYSICAL_ADDRESS AcpiS3ContextBuffer;\r
399 ACPI_S3_CONTEXT *AcpiS3Context;\r
400 STATIC BOOLEAN AlreadyEntered;\r
401 IA32_DESCRIPTOR *Idtr;\r
402 IA32_IDT_GATE_DESCRIPTOR *IdtGate;\r
403\r
404 DEBUG ((EFI_D_INFO, "S3Ready!\n"));\r
405\r
406 //\r
407 // Platform may invoke AcpiS3Save->S3Save() before ExitPmAuth, because we need save S3 information there, while BDS ReadyToBoot may invoke it again.\r
408 // So if 2nd S3Save() is triggered later, we need ignore it.\r
409 //\r
410 if (AlreadyEntered) {\r
411 return EFI_SUCCESS;\r
412 }\r
413 AlreadyEntered = TRUE;\r
414\r
415 AcpiS3Context = AllocateAcpiNvsMemoryBelow4G (sizeof(*AcpiS3Context));\r
416 ASSERT (AcpiS3Context != NULL);\r
417 AcpiS3ContextBuffer = (EFI_PHYSICAL_ADDRESS)(UINTN)AcpiS3Context;\r
418\r
419 //\r
420 // Get ACPI Table because we will save its position to variable\r
421 //\r
422 AcpiS3Context->AcpiFacsTable = (EFI_PHYSICAL_ADDRESS)(UINTN)FindAcpiFacsTable ();\r
423 ASSERT (AcpiS3Context->AcpiFacsTable != 0);\r
424\r
425 IdtGate = AllocateAcpiNvsMemoryBelow4G (sizeof(IA32_IDT_GATE_DESCRIPTOR) * 0x100 + sizeof(IA32_DESCRIPTOR));\r
426 Idtr = (IA32_DESCRIPTOR *)(IdtGate + 0x100);\r
427 Idtr->Base = (UINTN)IdtGate;\r
428 Idtr->Limit = (UINT16)(sizeof(IA32_IDT_GATE_DESCRIPTOR) * 0x100 - 1);\r
429 AcpiS3Context->IdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)Idtr;\r
430\r
431 Status = SaveLockBox (\r
432 &mAcpiS3IdtrProfileGuid,\r
433 (VOID *)(UINTN)Idtr,\r
434 (UINTN)sizeof(IA32_DESCRIPTOR)\r
435 );\r
436 ASSERT_EFI_ERROR (Status);\r
437\r
438 Status = SetLockBoxAttributes (&mAcpiS3IdtrProfileGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);\r
439 ASSERT_EFI_ERROR (Status);\r
440\r
441 //\r
442 // Allocate page table\r
443 //\r
444 AcpiS3Context->S3NvsPageTableAddress = S3CreateIdentityMappingPageTables ();\r
445\r
446 //\r
447 // Allocate stack\r
448 //\r
449 AcpiS3Context->BootScriptStackSize = PcdGet32 (PcdS3BootScriptStackSize);\r
450 AcpiS3Context->BootScriptStackBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateAcpiNvsMemoryBelow4G (PcdGet32 (PcdS3BootScriptStackSize));\r
451 ASSERT (AcpiS3Context->BootScriptStackBase != 0);\r
452\r
453 //\r
454 // Allocate a code buffer < 4G for S3 debug to load external code\r
455 //\r
456 AcpiS3Context->S3DebugBufferAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateAcpiNvsMemoryBelow4G (EFI_PAGE_SIZE);\r
457\r
458 DEBUG((EFI_D_INFO, "AcpiS3Context: AcpiFacsTable is 0x%8x\n", AcpiS3Context->AcpiFacsTable));\r
459 DEBUG((EFI_D_INFO, "AcpiS3Context: IdtrProfile is 0x%8x\n", AcpiS3Context->IdtrProfile));\r
460 DEBUG((EFI_D_INFO, "AcpiS3Context: S3NvsPageTableAddress is 0x%8x\n", AcpiS3Context->S3NvsPageTableAddress));\r
461 DEBUG((EFI_D_INFO, "AcpiS3Context: S3DebugBufferAddress is 0x%8x\n", AcpiS3Context->S3DebugBufferAddress));\r
462\r
463 Status = SaveLockBox (\r
464 &gEfiAcpiVariableGuid,\r
465 &AcpiS3ContextBuffer,\r
466 sizeof(AcpiS3ContextBuffer)\r
467 );\r
468 ASSERT_EFI_ERROR (Status);\r
469\r
470 Status = SaveLockBox (\r
471 &gEfiAcpiS3ContextGuid,\r
472 (VOID *)(UINTN)AcpiS3Context,\r
473 (UINTN)sizeof(*AcpiS3Context)\r
474 );\r
475 ASSERT_EFI_ERROR (Status);\r
476\r
477 Status = SetLockBoxAttributes (&gEfiAcpiS3ContextGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);\r
478 ASSERT_EFI_ERROR (Status);\r
479\r
480 if (FeaturePcdGet(PcdFrameworkCompatibilitySupport)) {\r
481 S3ReadyThunkPlatform (AcpiS3Context);\r
482 }\r
483\r
484 return EFI_SUCCESS;\r
485}\r
486\r
487/**\r
488 The Driver Entry Point.\r
489 \r
490 The function is the driver Entry point which will produce AcpiS3SaveProtocol.\r
491 \r
492 @param ImageHandle A handle for the image that is initializing this driver\r
493 @param SystemTable A pointer to the EFI system table\r
494\r
495 @retval EFI_SUCCESS: Driver initialized successfully\r
496 @retval EFI_LOAD_ERROR: Failed to Initialize or has been loaded\r
497 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources\r
498\r
499**/\r
500EFI_STATUS\r
501EFIAPI\r
502InstallAcpiS3Save (\r
503 IN EFI_HANDLE ImageHandle,\r
504 IN EFI_SYSTEM_TABLE *SystemTable\r
505 )\r
506{\r
507 EFI_STATUS Status;\r
508\r
509 if (!FeaturePcdGet(PcdPlatformCsmSupport)) {\r
510 //\r
511 // More memory for no CSM tip, because GDT need relocation\r
512 //\r
513 mLegacyRegionSize = 0x250;\r
514 } else {\r
515 mLegacyRegionSize = 0x100;\r
516 }\r
517\r
518 if (FeaturePcdGet(PcdFrameworkCompatibilitySupport)) {\r
519 InstallAcpiS3SaveThunk ();\r
520 }\r
521\r
522 Status = gBS->InstallProtocolInterface (\r
523 &ImageHandle,\r
524 &gEfiAcpiS3SaveProtocolGuid,\r
525 EFI_NATIVE_INTERFACE,\r
526 &mS3Save\r
527 );\r
528 ASSERT_EFI_ERROR (Status);\r
529 return Status;\r
530}\r