]>
Commit | Line | Data |
---|---|---|
13d4af68 | 1 | /** @file\r |
2 | This is an implementation of the AcpiVariable platform field for ECP platform.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions\r | |
8 | of the BSD License which accompanies this distribution. The\r | |
9 | 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 | typedef struct {\r | |
18 | EFI_PHYSICAL_ADDRESS AcpiReservedMemoryBase; <<===\r | |
19 | UINT32 AcpiReservedMemorySize; <<===\r | |
20 | EFI_PHYSICAL_ADDRESS S3ReservedLowMemoryBase;\r | |
21 | EFI_PHYSICAL_ADDRESS AcpiBootScriptTable;\r | |
22 | EFI_PHYSICAL_ADDRESS RuntimeScriptTableBase;\r | |
23 | EFI_PHYSICAL_ADDRESS AcpiFacsTable;\r | |
24 | UINT64 SystemMemoryLength; <<===\r | |
25 | ACPI_CPU_DATA_COMPATIBILITY AcpiCpuData;\r | |
26 | EFI_PHYSICAL_ADDRESS VideoOpromAddress;\r | |
27 | UINT32 VideoOpromSize;\r | |
28 | EFI_PHYSICAL_ADDRESS S3DebugBufferAddress; \r | |
29 | EFI_PHYSICAL_ADDRESS S3ResumeNvsEntryPoint; \r | |
30 | } ACPI_VARIABLE_SET_COMPATIBILITY;\r | |
31 | \r | |
32 | **/\r | |
33 | \r | |
34 | #include <FrameworkDxe.h>\r | |
35 | #include <Library/BaseLib.h>\r | |
36 | #include <Library/BaseMemoryLib.h>\r | |
37 | #include <Library/UefiBootServicesTableLib.h>\r | |
38 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
39 | #include <Library/HobLib.h>\r | |
40 | #include <Library/PcdLib.h>\r | |
41 | #include <Library/DebugLib.h>\r | |
42 | #include <Protocol/FrameworkMpService.h>\r | |
43 | #include <Guid/AcpiVariableCompatibility.h>\r | |
44 | #include <Guid/AcpiS3Context.h>\r | |
45 | \r | |
46 | GLOBAL_REMOVE_IF_UNREFERENCED\r | |
47 | ACPI_VARIABLE_SET_COMPATIBILITY *mAcpiVariableSetCompatibility = NULL;\r | |
48 | \r | |
49 | /**\r | |
50 | Allocate EfiACPIMemoryNVS below 4G memory address.\r | |
51 | \r | |
52 | This function allocates EfiACPIMemoryNVS below 4G memory address.\r | |
53 | \r | |
54 | @param Size Size of memory to allocate.\r | |
55 | \r | |
56 | @return Allocated address for output.\r | |
57 | \r | |
58 | **/\r | |
59 | VOID*\r | |
60 | AllocateAcpiNvsMemoryBelow4G (\r | |
61 | IN UINTN Size\r | |
62 | );\r | |
63 | \r | |
64 | /**\r | |
65 | Hook point for AcpiVariableThunkPlatform for S3Ready.\r | |
66 | \r | |
67 | @param AcpiS3Context ACPI s3 context\r | |
68 | **/\r | |
69 | VOID\r | |
70 | S3ReadyThunkPlatform (\r | |
71 | IN ACPI_S3_CONTEXT *AcpiS3Context\r | |
72 | )\r | |
73 | {\r | |
74 | EFI_PHYSICAL_ADDRESS AcpiMemoryBase;\r | |
75 | UINT32 AcpiMemorySize;\r | |
76 | EFI_PEI_HOB_POINTERS Hob;\r | |
77 | UINT64 MemoryLength;\r | |
78 | \r | |
79 | DEBUG ((EFI_D_INFO, "S3ReadyThunkPlatform\n"));\r | |
80 | \r | |
81 | //\r | |
82 | // Allocate ACPI reserved memory under 4G\r | |
83 | //\r | |
84 | AcpiMemoryBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateAcpiNvsMemoryBelow4G (PcdGet32 (PcdS3AcpiReservedMemorySize));\r | |
85 | ASSERT (AcpiMemoryBase != 0);\r | |
86 | AcpiMemorySize = PcdGet32 (PcdS3AcpiReservedMemorySize);\r | |
87 | \r | |
88 | //\r | |
89 | // Calculate the system memory length by memory hobs\r | |
90 | //\r | |
91 | MemoryLength = 0x100000;\r | |
92 | Hob.Raw = GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);\r | |
93 | ASSERT (Hob.Raw != NULL);\r | |
94 | while ((Hob.Raw != NULL) && (!END_OF_HOB_LIST (Hob))) {\r | |
95 | if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {\r | |
96 | //\r | |
97 | // Skip the memory region below 1MB\r | |
98 | //\r | |
99 | if (Hob.ResourceDescriptor->PhysicalStart >= 0x100000) {\r | |
100 | MemoryLength += Hob.ResourceDescriptor->ResourceLength;\r | |
101 | }\r | |
102 | }\r | |
103 | Hob.Raw = GET_NEXT_HOB (Hob);\r | |
104 | Hob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, Hob.Raw);\r | |
105 | }\r | |
106 | \r | |
107 | mAcpiVariableSetCompatibility->AcpiReservedMemoryBase = AcpiMemoryBase;\r | |
108 | mAcpiVariableSetCompatibility->AcpiReservedMemorySize = AcpiMemorySize;\r | |
109 | mAcpiVariableSetCompatibility->SystemMemoryLength = MemoryLength;\r | |
110 | \r | |
111 | DEBUG((EFI_D_INFO, "AcpiVariableThunkPlatform: AcpiMemoryBase is 0x%8x\n", mAcpiVariableSetCompatibility->AcpiReservedMemoryBase));\r | |
112 | DEBUG((EFI_D_INFO, "AcpiVariableThunkPlatform: AcpiMemorySize is 0x%8x\n", mAcpiVariableSetCompatibility->AcpiReservedMemorySize));\r | |
113 | DEBUG((EFI_D_INFO, "AcpiVariableThunkPlatform: SystemMemoryLength is 0x%8x\n", mAcpiVariableSetCompatibility->SystemMemoryLength));\r | |
114 | \r | |
115 | return ;\r | |
116 | }\r | |
117 | \r | |
118 | /**\r | |
119 | Hook point for AcpiVariableThunkPlatform for InstallAcpiS3Save.\r | |
120 | **/\r | |
121 | VOID\r | |
122 | InstallAcpiS3SaveThunk (\r | |
123 | VOID\r | |
124 | )\r | |
125 | {\r | |
126 | EFI_STATUS Status;\r | |
127 | FRAMEWORK_EFI_MP_SERVICES_PROTOCOL *FrameworkMpService;\r | |
128 | UINTN VarSize;\r | |
129 | \r | |
130 | Status = gBS->LocateProtocol (\r | |
131 | &gFrameworkEfiMpServiceProtocolGuid,\r | |
132 | NULL,\r | |
133 | (VOID**) &FrameworkMpService\r | |
134 | );\r | |
135 | if (!EFI_ERROR (Status)) {\r | |
136 | //\r | |
137 | // On ECP platform, if framework CPU drivers are in use, The compatible version of ACPI variable set \r | |
138 | // should be produced by CPU driver. \r | |
139 | //\r | |
140 | VarSize = sizeof (mAcpiVariableSetCompatibility);\r | |
141 | Status = gRT->GetVariable (\r | |
142 | ACPI_GLOBAL_VARIABLE,\r | |
143 | &gEfiAcpiVariableCompatiblityGuid,\r | |
144 | NULL,\r | |
145 | &VarSize,\r | |
146 | &mAcpiVariableSetCompatibility\r | |
147 | );\r | |
148 | ASSERT_EFI_ERROR (Status);\r | |
149 | } else {\r | |
150 | //\r | |
151 | // Allocate/initialize the compatible version of Acpi Variable Set since Framework chipset/platform \r | |
152 | // driver need this variable\r | |
153 | //\r | |
154 | mAcpiVariableSetCompatibility = AllocateAcpiNvsMemoryBelow4G (sizeof(ACPI_VARIABLE_SET_COMPATIBILITY));\r | |
155 | Status = gRT->SetVariable (\r | |
156 | ACPI_GLOBAL_VARIABLE,\r | |
157 | &gEfiAcpiVariableCompatiblityGuid,\r | |
158 | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r | |
159 | sizeof(mAcpiVariableSetCompatibility),\r | |
160 | &mAcpiVariableSetCompatibility\r | |
161 | );\r | |
162 | ASSERT_EFI_ERROR (Status);\r | |
163 | }\r | |
164 | \r | |
165 | DEBUG((EFI_D_INFO, "AcpiVariableSetCompatibility is 0x%8x\n", mAcpiVariableSetCompatibility));\r | |
166 | }\r |