]>
Commit | Line | Data |
---|---|---|
cd204e01 SM |
1 | /** @file\r |
2 | FADT Table Generator\r | |
3 | \r | |
4 | Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.\r | |
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 | @par Reference(s):\r | |
14 | - ACPI 6.2 Specification - Errata A, September 2017\r | |
15 | \r | |
16 | **/\r | |
17 | \r | |
18 | #include <Library/AcpiLib.h>\r | |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Protocol/AcpiTable.h>\r | |
21 | \r | |
22 | // Module specific include files.\r | |
23 | #include <AcpiTableGenerator.h>\r | |
24 | #include <ConfigurationManagerObject.h>\r | |
25 | #include <ConfigurationManagerHelper.h>\r | |
26 | #include <Library/TableHelperLib.h>\r | |
27 | #include <Protocol/ConfigurationManagerProtocol.h>\r | |
28 | \r | |
29 | /** ARM standard FADT Generator\r | |
30 | \r | |
31 | Requirements:\r | |
32 | The following Configuration Manager Object(s) are required by\r | |
33 | this Generator:\r | |
34 | - EArmObjPowerManagementProfileInfo\r | |
35 | - EArmObjBootArchInfo\r | |
36 | - EArmObjHypervisorVendorIdentity (OPTIONAL)\r | |
37 | */\r | |
38 | \r | |
39 | /** This macro defines the FADT flag options for ARM Platforms.\r | |
40 | */\r | |
41 | #define FADT_FLAGS (EFI_ACPI_6_2_HW_REDUCED_ACPI | \\r | |
42 | EFI_ACPI_6_2_LOW_POWER_S0_IDLE_CAPABLE)\r | |
43 | \r | |
44 | /** This macro defines the valid mask for the FADT flag option\r | |
45 | if HW_REDUCED_ACPI flag in the table is set.\r | |
46 | \r | |
47 | Invalid bits are: 1, 2, 3,7, 8, 13, 14,16, 17 and\r | |
48 | 22-31 (reserved).\r | |
49 | \r | |
50 | Valid bits are:\r | |
51 | EFI_ACPI_6_2_WBINVD BIT0\r | |
52 | EFI_ACPI_6_2_PWR_BUTTON BIT4\r | |
53 | EFI_ACPI_6_2_SLP_BUTTON BIT5\r | |
54 | EFI_ACPI_6_2_FIX_RTC BIT6\r | |
55 | EFI_ACPI_6_2_DCK_CAP BIT9\r | |
56 | EFI_ACPI_6_2_RESET_REG_SUP BIT10\r | |
57 | EFI_ACPI_6_2_SEALED_CASE BIT11\r | |
58 | EFI_ACPI_6_2_HEADLESS BIT12\r | |
59 | EFI_ACPI_6_2_USE_PLATFORM_CLOCK BIT15\r | |
60 | EFI_ACPI_6_2_FORCE_APIC_CLUSTER_MODEL BIT18\r | |
61 | EFI_ACPI_6_2_FORCE_APIC_PHYSICAL_DESTINATION_MODE BIT19\r | |
62 | EFI_ACPI_6_2_HW_REDUCED_ACPI BIT20\r | |
63 | EFI_ACPI_6_2_LOW_POWER_S0_IDLE_CAPABLE BIT21\r | |
64 | */\r | |
65 | #define VALID_HARDWARE_REDUCED_FLAG_MASK ( \\r | |
66 | EFI_ACPI_6_2_WBINVD | \\r | |
67 | EFI_ACPI_6_2_PWR_BUTTON | \\r | |
68 | EFI_ACPI_6_2_SLP_BUTTON | \\r | |
69 | EFI_ACPI_6_2_FIX_RTC | \\r | |
70 | EFI_ACPI_6_2_DCK_CAP | \\r | |
71 | EFI_ACPI_6_2_RESET_REG_SUP | \\r | |
72 | EFI_ACPI_6_2_SEALED_CASE | \\r | |
73 | EFI_ACPI_6_2_HEADLESS | \\r | |
74 | EFI_ACPI_6_2_USE_PLATFORM_CLOCK | \\r | |
75 | EFI_ACPI_6_2_FORCE_APIC_CLUSTER_MODEL | \\r | |
76 | EFI_ACPI_6_2_FORCE_APIC_PHYSICAL_DESTINATION_MODE | \\r | |
77 | EFI_ACPI_6_2_HW_REDUCED_ACPI | \\r | |
78 | EFI_ACPI_6_2_LOW_POWER_S0_IDLE_CAPABLE)\r | |
79 | \r | |
80 | #pragma pack(1)\r | |
81 | \r | |
82 | /** The AcpiFadt is a template EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE\r | |
83 | structure used for generating the FADT Table.\r | |
84 | Note: fields marked with "{Template}" will be updated dynamically.\r | |
85 | */\r | |
86 | STATIC\r | |
87 | EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE AcpiFadt = {\r | |
88 | ACPI_HEADER (\r | |
89 | EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,\r | |
90 | EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE,\r | |
91 | EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION\r | |
92 | ),\r | |
93 | // UINT32 FirmwareCtrl\r | |
94 | 0,\r | |
95 | // UINT32 Dsdt\r | |
96 | 0,\r | |
97 | // UINT8 Reserved0\r | |
98 | EFI_ACPI_RESERVED_BYTE,\r | |
99 | // UINT8 PreferredPmProfile\r | |
100 | EFI_ACPI_6_2_PM_PROFILE_UNSPECIFIED, // {Template}: Power Management Profile\r | |
101 | // UINT16 SciInt\r | |
102 | 0,\r | |
103 | // UINT32 SmiCmd\r | |
104 | 0,\r | |
105 | // UINT8 AcpiEnable\r | |
106 | 0,\r | |
107 | // UINT8 AcpiDisable\r | |
108 | 0,\r | |
109 | // UINT8 S4BiosReq\r | |
110 | 0,\r | |
111 | // UINT8 PstateCnt\r | |
112 | 0,\r | |
113 | // UINT32 Pm1aEvtBlk\r | |
114 | 0,\r | |
115 | // UINT32 Pm1bEvtBlk\r | |
116 | 0,\r | |
117 | // UINT32 Pm1aCntBlk\r | |
118 | 0,\r | |
119 | // UINT32 Pm1bCntBlk\r | |
120 | 0,\r | |
121 | // UINT32 Pm2CntBlk\r | |
122 | 0,\r | |
123 | // UINT32 PmTmrBlk\r | |
124 | 0,\r | |
125 | // UINT32 Gpe0Blk\r | |
126 | 0,\r | |
127 | // UINT32 Gpe1Blk\r | |
128 | 0,\r | |
129 | // UINT8 Pm1EvtLen\r | |
130 | 0,\r | |
131 | // UINT8 Pm1CntLen\r | |
132 | 0,\r | |
133 | // UINT8 Pm2CntLen\r | |
134 | 0,\r | |
135 | // UINT8 PmTmrLen\r | |
136 | 0,\r | |
137 | // UINT8 Gpe0BlkLen\r | |
138 | 0,\r | |
139 | // UINT8 Gpe1BlkLen\r | |
140 | 0,\r | |
141 | // UINT8 Gpe1Base\r | |
142 | 0,\r | |
143 | // UINT8 CstCnt\r | |
144 | 0,\r | |
145 | // UINT16 PLvl2Lat\r | |
146 | 0,\r | |
147 | // UINT16 PLvl3Lat\r | |
148 | 0,\r | |
149 | // UINT16 FlushSize\r | |
150 | 0,\r | |
151 | // UINT16 FlushStride\r | |
152 | 0,\r | |
153 | // UINT8 DutyOffset\r | |
154 | 0,\r | |
155 | // UINT8 DutyWidth\r | |
156 | 0,\r | |
157 | // UINT8 DayAlrm\r | |
158 | 0,\r | |
159 | // UINT8 MonAlrm\r | |
160 | 0,\r | |
161 | // UINT8 Century\r | |
162 | 0,\r | |
163 | // UINT16 IaPcBootArch\r | |
164 | 0,\r | |
165 | // UINT8 Reserved1\r | |
166 | 0,\r | |
167 | // UINT32 Flags\r | |
168 | FADT_FLAGS,\r | |
169 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE ResetReg\r | |
170 | NULL_GAS,\r | |
171 | // UINT8 ResetValue\r | |
172 | 0,\r | |
173 | // UINT16 ArmBootArch\r | |
174 | EFI_ACPI_6_2_ARM_PSCI_COMPLIANT, // {Template}: ARM Boot Architecture Flags\r | |
175 | // UINT8 MinorRevision\r | |
176 | EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION,\r | |
177 | // UINT64 XFirmwareCtrl\r | |
178 | 0,\r | |
179 | // UINT64 XDsdt\r | |
180 | 0,\r | |
181 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk\r | |
182 | NULL_GAS,\r | |
183 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk\r | |
184 | NULL_GAS,\r | |
185 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk\r | |
186 | NULL_GAS,\r | |
187 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk\r | |
188 | NULL_GAS,\r | |
189 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk\r | |
190 | NULL_GAS,\r | |
191 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk\r | |
192 | NULL_GAS,\r | |
193 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE XGpe0Blk\r | |
194 | NULL_GAS,\r | |
195 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE XGpe1Blk\r | |
196 | NULL_GAS,\r | |
197 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE SleepControlReg\r | |
198 | NULL_GAS,\r | |
199 | // EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE SleepStatusReg\r | |
200 | NULL_GAS,\r | |
201 | // UINT64 HypervisorVendorIdentity\r | |
202 | EFI_ACPI_RESERVED_QWORD // {Template}: Hypervisor Vendor ID\r | |
203 | };\r | |
204 | \r | |
205 | #pragma pack()\r | |
206 | \r | |
207 | /** This macro expands to a function that retrieves the Power\r | |
208 | Management Profile Information from the Configuration Manager.\r | |
209 | */\r | |
210 | GET_OBJECT_LIST (\r | |
211 | EObjNameSpaceArm,\r | |
212 | EArmObjPowerManagementProfileInfo,\r | |
213 | CM_ARM_POWER_MANAGEMENT_PROFILE_INFO\r | |
214 | );\r | |
215 | \r | |
216 | /** This macro expands to a function that retrieves the Boot\r | |
217 | Architecture Information from the Configuration Manager.\r | |
218 | */\r | |
219 | GET_OBJECT_LIST (\r | |
220 | EObjNameSpaceArm,\r | |
221 | EArmObjBootArchInfo,\r | |
222 | CM_ARM_BOOT_ARCH_INFO\r | |
223 | );\r | |
224 | \r | |
225 | /** This macro expands to a function that retrieves the Hypervisor\r | |
226 | Vendor ID from the Configuration Manager.\r | |
227 | */\r | |
228 | GET_OBJECT_LIST (\r | |
229 | EObjNameSpaceArm,\r | |
230 | EArmObjHypervisorVendorIdentity,\r | |
231 | CM_ARM_HYPERVISOR_VENDOR_ID\r | |
232 | );\r | |
233 | \r | |
234 | /** This macro expands to a function that retrieves the Fixed\r | |
235 | feature flags for the platform from the Configuration Manager.\r | |
236 | */\r | |
237 | GET_OBJECT_LIST (\r | |
238 | EObjNameSpaceArm,\r | |
239 | EArmObjFixedFeatureFlags,\r | |
240 | CM_ARM_FIXED_FEATURE_FLAGS\r | |
241 | );\r | |
242 | \r | |
243 | /** Update the Power Management Profile information in the FADT Table.\r | |
244 | \r | |
245 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager\r | |
246 | Protocol Interface.\r | |
247 | \r | |
248 | @retval EFI_SUCCESS Success.\r | |
249 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
250 | @retval EFI_NOT_FOUND The required object was not found.\r | |
251 | @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration\r | |
252 | Manager is less than the Object size for the\r | |
253 | requested object.\r | |
254 | **/\r | |
255 | STATIC\r | |
256 | EFI_STATUS\r | |
257 | EFIAPI\r | |
258 | FadtAddPmProfileInfo (\r | |
259 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol\r | |
260 | )\r | |
261 | {\r | |
262 | EFI_STATUS Status;\r | |
263 | CM_ARM_POWER_MANAGEMENT_PROFILE_INFO * PmProfile;\r | |
264 | \r | |
265 | ASSERT (CfgMgrProtocol != NULL);\r | |
266 | \r | |
267 | // Get the Power Management Profile from the Platform Configuration Manager\r | |
268 | Status = GetEArmObjPowerManagementProfileInfo (\r | |
269 | CfgMgrProtocol,\r | |
270 | CM_NULL_TOKEN,\r | |
271 | &PmProfile,\r | |
272 | NULL\r | |
273 | );\r | |
274 | if (EFI_ERROR (Status)) {\r | |
275 | DEBUG ((\r | |
276 | DEBUG_ERROR,\r | |
277 | "ERROR: FADT: Failed to get Power Management Profile information." \\r | |
278 | " Status = %r\n",\r | |
279 | Status\r | |
280 | ));\r | |
281 | goto error_handler;\r | |
282 | }\r | |
283 | \r | |
284 | DEBUG ((\r | |
285 | DEBUG_INFO,\r | |
286 | "FADT: PreferredPmProfile = 0x%x\n",\r | |
287 | PmProfile->PowerManagementProfile\r | |
288 | ));\r | |
289 | \r | |
290 | AcpiFadt.PreferredPmProfile = PmProfile->PowerManagementProfile;\r | |
291 | \r | |
292 | error_handler:\r | |
293 | return Status;\r | |
294 | }\r | |
295 | \r | |
296 | /** Updates the Boot Architecture information in the FADT Table.\r | |
297 | \r | |
298 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager\r | |
299 | Protocol Interface.\r | |
300 | \r | |
301 | @retval EFI_SUCCESS Success.\r | |
302 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
303 | @retval EFI_NOT_FOUND The required object was not found.\r | |
304 | @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration\r | |
305 | Manager is less than the Object size for the\r | |
306 | requested object.\r | |
307 | **/\r | |
308 | STATIC\r | |
309 | EFI_STATUS\r | |
310 | EFIAPI\r | |
311 | FadtAddBootArchInfo (\r | |
312 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol\r | |
313 | )\r | |
314 | {\r | |
315 | EFI_STATUS Status;\r | |
316 | CM_ARM_BOOT_ARCH_INFO * BootArchInfo;\r | |
317 | \r | |
318 | ASSERT (CfgMgrProtocol != NULL);\r | |
319 | \r | |
320 | // Get the Boot Architecture flags from the Platform Configuration Manager\r | |
321 | Status = GetEArmObjBootArchInfo (\r | |
322 | CfgMgrProtocol,\r | |
323 | CM_NULL_TOKEN,\r | |
324 | &BootArchInfo,\r | |
325 | NULL\r | |
326 | );\r | |
327 | if (EFI_ERROR (Status)) {\r | |
328 | DEBUG ((\r | |
329 | DEBUG_ERROR,\r | |
330 | "ERROR: FADT: Failed to get Boot Architecture flags. Status = %r\n",\r | |
331 | Status\r | |
332 | ));\r | |
333 | goto error_handler;\r | |
334 | }\r | |
335 | \r | |
336 | DEBUG ((\r | |
337 | DEBUG_INFO,\r | |
338 | "FADT BootArchFlag = 0x%x\n",\r | |
339 | BootArchInfo->BootArchFlags\r | |
340 | ));\r | |
341 | \r | |
342 | AcpiFadt.ArmBootArch = BootArchInfo->BootArchFlags;\r | |
343 | \r | |
344 | error_handler:\r | |
345 | return Status;\r | |
346 | }\r | |
347 | \r | |
348 | /** Update the Hypervisor Vendor ID in the FADT Table.\r | |
349 | \r | |
350 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager\r | |
351 | Protocol Interface.\r | |
352 | \r | |
353 | @retval EFI_SUCCESS Success.\r | |
354 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
355 | @retval EFI_NOT_FOUND The required object was not found.\r | |
356 | @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration\r | |
357 | Manager is less than the Object size for the\r | |
358 | requested object.\r | |
359 | **/\r | |
360 | STATIC\r | |
361 | EFI_STATUS\r | |
362 | EFIAPI\r | |
363 | FadtAddHypervisorVendorId (\r | |
364 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol\r | |
365 | )\r | |
366 | {\r | |
367 | EFI_STATUS Status;\r | |
368 | CM_ARM_HYPERVISOR_VENDOR_ID * HypervisorVendorInfo;\r | |
369 | \r | |
370 | ASSERT (CfgMgrProtocol != NULL);\r | |
371 | \r | |
372 | // Get the Hypervisor Vendor ID from the Platform Configuration Manager\r | |
373 | Status = GetEArmObjHypervisorVendorIdentity (\r | |
374 | CfgMgrProtocol,\r | |
375 | CM_NULL_TOKEN,\r | |
376 | &HypervisorVendorInfo,\r | |
377 | NULL\r | |
378 | );\r | |
379 | if (EFI_ERROR (Status)) {\r | |
380 | if (Status == EFI_NOT_FOUND) {\r | |
381 | DEBUG ((\r | |
382 | DEBUG_INFO,\r | |
383 | "INFO: FADT: Platform does not have a Hypervisor Vendor ID."\r | |
384 | "Status = %r\n",\r | |
385 | Status\r | |
386 | ));\r | |
387 | } else {\r | |
388 | DEBUG ((\r | |
389 | DEBUG_ERROR,\r | |
390 | "ERROR: FADT: Failed to get Hypervisor Vendor ID. Status = %r\n",\r | |
391 | Status\r | |
392 | ));\r | |
393 | }\r | |
394 | goto error_handler;\r | |
395 | }\r | |
396 | \r | |
397 | DEBUG ((\r | |
398 | DEBUG_INFO,\r | |
399 | "FADT: EArmObjHypervisorVendorIdentity = 0x%lx\n",\r | |
400 | HypervisorVendorInfo->HypervisorVendorId\r | |
401 | ));\r | |
402 | \r | |
403 | AcpiFadt.HypervisorVendorIdentity = HypervisorVendorInfo->HypervisorVendorId;\r | |
404 | \r | |
405 | error_handler:\r | |
406 | return Status;\r | |
407 | }\r | |
408 | \r | |
409 | /** Update the Fixed Feature Flags in the FADT Table.\r | |
410 | \r | |
411 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager\r | |
412 | Protocol Interface.\r | |
413 | \r | |
414 | @retval EFI_SUCCESS Success.\r | |
415 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
416 | @retval EFI_NOT_FOUND The required object was not found.\r | |
417 | @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration\r | |
418 | Manager is less than the Object size for the\r | |
419 | requested object.\r | |
420 | **/\r | |
421 | STATIC\r | |
422 | EFI_STATUS\r | |
423 | EFIAPI\r | |
424 | FadtAddFixedFeatureFlags (\r | |
425 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol\r | |
426 | )\r | |
427 | {\r | |
428 | EFI_STATUS Status;\r | |
429 | CM_ARM_FIXED_FEATURE_FLAGS * FixedFeatureFlags;\r | |
430 | \r | |
431 | ASSERT (CfgMgrProtocol != NULL);\r | |
432 | \r | |
433 | // Get the Fixed feature flags from the Platform Configuration Manager\r | |
434 | Status = GetEArmObjFixedFeatureFlags (\r | |
435 | CfgMgrProtocol,\r | |
436 | CM_NULL_TOKEN,\r | |
437 | &FixedFeatureFlags,\r | |
438 | NULL\r | |
439 | );\r | |
440 | if (EFI_ERROR (Status)) {\r | |
441 | if (Status == EFI_NOT_FOUND) {\r | |
442 | DEBUG ((\r | |
443 | DEBUG_INFO,\r | |
444 | "INFO: FADT: Platform does not define additional Fixed feature flags."\r | |
445 | "Status = %r\n",\r | |
446 | Status\r | |
447 | ));\r | |
448 | } else {\r | |
449 | DEBUG ((\r | |
450 | DEBUG_ERROR,\r | |
451 | "ERROR: FADT: Failed to get Fixed feature flags. Status = %r\n",\r | |
452 | Status\r | |
453 | ));\r | |
454 | }\r | |
455 | goto error_handler;\r | |
456 | }\r | |
457 | \r | |
458 | DEBUG ((\r | |
459 | DEBUG_INFO,\r | |
460 | "FADT: EArmObjFixedFeatureFlags = 0x%x\n",\r | |
461 | FixedFeatureFlags->Flags\r | |
462 | ));\r | |
463 | \r | |
464 | if ((FixedFeatureFlags->Flags & ~(VALID_HARDWARE_REDUCED_FLAG_MASK)) != 0) {\r | |
465 | DEBUG ((\r | |
466 | DEBUG_WARN,\r | |
467 | "FADT: Invalid Fixed feature flags defined by platform,"\r | |
468 | "Invalid Flags bits are = 0x%x\n",\r | |
469 | (FixedFeatureFlags->Flags & ~(VALID_HARDWARE_REDUCED_FLAG_MASK))\r | |
470 | ));\r | |
471 | }\r | |
472 | \r | |
473 | AcpiFadt.Flags |= (FixedFeatureFlags->Flags &\r | |
474 | VALID_HARDWARE_REDUCED_FLAG_MASK);\r | |
475 | \r | |
476 | error_handler:\r | |
477 | return Status;\r | |
478 | }\r | |
479 | \r | |
480 | /** Construct the FADT table.\r | |
481 | \r | |
482 | This function invokes the Configuration Manager protocol interface\r | |
483 | to get the required hardware information for generating the ACPI\r | |
484 | table.\r | |
485 | \r | |
486 | If this function allocates any resources then they must be freed\r | |
487 | in the FreeXXXXTableResources function.\r | |
488 | \r | |
489 | @param [in] This Pointer to the table generator.\r | |
490 | @param [in] AcpiTableInfo Pointer to the ACPI Table Info.\r | |
491 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager\r | |
492 | Protocol Interface.\r | |
493 | @param [out] Table Pointer to the constructed ACPI Table.\r | |
494 | \r | |
495 | @retval EFI_SUCCESS Table generated successfully.\r | |
496 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
497 | @retval EFI_NOT_FOUND The required object was not found.\r | |
498 | @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration\r | |
499 | Manager is less than the Object size for the\r | |
500 | requested object.\r | |
501 | **/\r | |
502 | STATIC\r | |
503 | EFI_STATUS\r | |
504 | EFIAPI\r | |
505 | BuildFadtTable (\r | |
506 | IN CONST ACPI_TABLE_GENERATOR * CONST This,\r | |
507 | IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,\r | |
508 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,\r | |
509 | OUT EFI_ACPI_DESCRIPTION_HEADER ** CONST Table\r | |
510 | )\r | |
511 | {\r | |
512 | EFI_STATUS Status;\r | |
513 | \r | |
514 | ASSERT (This != NULL);\r | |
515 | ASSERT (AcpiTableInfo != NULL);\r | |
516 | ASSERT (CfgMgrProtocol != NULL);\r | |
517 | ASSERT (Table != NULL);\r | |
518 | ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);\r | |
519 | ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);\r | |
520 | \r | |
521 | if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) ||\r | |
522 | (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision)) {\r | |
523 | DEBUG ((\r | |
524 | DEBUG_ERROR,\r | |
525 | "ERROR: FADT: Requested table revision = %d, is not supported."\r | |
526 | "Supported table revision: Minimum = %d, Maximum = %d\n",\r | |
527 | AcpiTableInfo->AcpiTableRevision,\r | |
528 | This->MinAcpiTableRevision,\r | |
529 | This->AcpiTableRevision\r | |
530 | ));\r | |
531 | return EFI_INVALID_PARAMETER;\r | |
532 | }\r | |
533 | \r | |
534 | *Table = NULL;\r | |
535 | \r | |
536 | Status = AddAcpiHeader (\r | |
537 | CfgMgrProtocol,\r | |
538 | This,\r | |
539 | (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiFadt,\r | |
c788bdab | 540 | AcpiTableInfo,\r |
cd204e01 SM |
541 | sizeof (EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE)\r |
542 | );\r | |
543 | if (EFI_ERROR (Status)) {\r | |
544 | DEBUG ((\r | |
545 | DEBUG_ERROR,\r | |
546 | "ERROR: FADT: Failed to add ACPI header. Status = %r\n",\r | |
547 | Status\r | |
548 | ));\r | |
549 | goto error_handler;\r | |
550 | }\r | |
551 | \r | |
552 | // Update PmProfile Info\r | |
553 | Status = FadtAddPmProfileInfo (CfgMgrProtocol);\r | |
554 | if (EFI_ERROR (Status)) {\r | |
555 | goto error_handler;\r | |
556 | }\r | |
557 | \r | |
558 | // Update BootArch Info\r | |
559 | Status = FadtAddBootArchInfo (CfgMgrProtocol);\r | |
560 | if (EFI_ERROR (Status)) {\r | |
561 | goto error_handler;\r | |
562 | }\r | |
563 | \r | |
564 | // Add the Hypervisor Vendor Id if present\r | |
565 | // Note if no hypervisor is present the zero bytes\r | |
566 | // will be placed in this field.\r | |
567 | Status = FadtAddHypervisorVendorId (CfgMgrProtocol);\r | |
568 | if (EFI_ERROR (Status)) {\r | |
569 | if (Status == EFI_NOT_FOUND) {\r | |
570 | DEBUG ((\r | |
571 | DEBUG_INFO,\r | |
572 | "INFO: FADT: No Hypervisor Vendor ID found," \\r | |
573 | " assuming no Hypervisor is present in the firmware.\n"\r | |
574 | ));\r | |
575 | } else {\r | |
576 | DEBUG ((\r | |
577 | DEBUG_ERROR,\r | |
578 | "ERROR: FADT: Error reading Hypervisor Vendor ID, Status = %r",\r | |
579 | Status\r | |
580 | ));\r | |
581 | goto error_handler;\r | |
582 | }\r | |
583 | }\r | |
584 | \r | |
585 | Status = FadtAddFixedFeatureFlags (CfgMgrProtocol);\r | |
586 | if (EFI_ERROR (Status)) {\r | |
587 | if (Status == EFI_NOT_FOUND) {\r | |
588 | DEBUG ((\r | |
589 | DEBUG_INFO,\r | |
590 | "INFO: FADT: No Fixed feature flags found," \\r | |
591 | " assuming no additional flags are defined for the platform.\n"\r | |
592 | ));\r | |
593 | Status = EFI_SUCCESS;\r | |
594 | } else {\r | |
595 | DEBUG ((\r | |
596 | DEBUG_ERROR,\r | |
597 | "ERROR: FADT: Error reading Fixed feature flags, Status = %r",\r | |
598 | Status\r | |
599 | ));\r | |
600 | goto error_handler;\r | |
601 | }\r | |
602 | }\r | |
603 | \r | |
604 | *Table = (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiFadt;\r | |
605 | error_handler:\r | |
606 | return Status;\r | |
607 | }\r | |
608 | \r | |
609 | /** This macro defines the FADT Table Generator revision.\r | |
610 | */\r | |
611 | #define FADT_GENERATOR_REVISION CREATE_REVISION (1, 0)\r | |
612 | \r | |
613 | /** The interface for the FADT Table Generator.\r | |
614 | */\r | |
615 | STATIC\r | |
616 | CONST\r | |
617 | ACPI_TABLE_GENERATOR FadtGenerator = {\r | |
618 | // Generator ID\r | |
619 | CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt),\r | |
620 | // Generator Description\r | |
621 | L"ACPI.STD.FADT.GENERATOR",\r | |
622 | // ACPI Table Signature\r | |
623 | EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,\r | |
624 | // ACPI Table Revision supported by this Generator\r | |
625 | EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,\r | |
626 | // Minimum supported ACPI Table Revision\r | |
627 | EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,\r | |
628 | // Creator ID\r | |
629 | TABLE_GENERATOR_CREATOR_ID_ARM,\r | |
630 | // Creator Revision\r | |
631 | FADT_GENERATOR_REVISION,\r | |
632 | // Build Table function\r | |
633 | BuildFadtTable,\r | |
634 | // No additional resources are allocated by the generator.\r | |
635 | // Hence the Free Resource function is not required.\r | |
636 | NULL,\r | |
637 | // Extended build function not needed\r | |
638 | NULL,\r | |
639 | // Extended build function not implemented by the generator.\r | |
640 | // Hence extended free resource function is not required.\r | |
641 | NULL\r | |
642 | };\r | |
643 | \r | |
644 | /** Register the Generator with the ACPI Table Factory.\r | |
645 | \r | |
646 | @param [in] ImageHandle The handle to the image.\r | |
647 | @param [in] SystemTable Pointer to the System Table.\r | |
648 | \r | |
649 | @retval EFI_SUCCESS The Generator is registered.\r | |
650 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
651 | @retval EFI_ALREADY_STARTED The Generator for the Table ID\r | |
652 | is already registered.\r | |
653 | **/\r | |
654 | EFI_STATUS\r | |
655 | EFIAPI\r | |
656 | AcpiFadtLibConstructor (\r | |
657 | IN CONST EFI_HANDLE ImageHandle,\r | |
658 | IN EFI_SYSTEM_TABLE * CONST SystemTable\r | |
659 | )\r | |
660 | {\r | |
661 | EFI_STATUS Status;\r | |
662 | Status = RegisterAcpiTableGenerator (&FadtGenerator);\r | |
663 | DEBUG ((DEBUG_INFO, "FADT: Register Generator. Status = %r\n", Status));\r | |
664 | ASSERT_EFI_ERROR (Status);\r | |
665 | return Status;\r | |
666 | }\r | |
667 | \r | |
668 | /** Deregister the Generator from the ACPI Table Factory.\r | |
669 | \r | |
670 | @param [in] ImageHandle The handle to the image.\r | |
671 | @param [in] SystemTable Pointer to the System Table.\r | |
672 | \r | |
673 | @retval EFI_SUCCESS The Generator is deregistered.\r | |
674 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
675 | @retval EFI_NOT_FOUND The Generator is not registered.\r | |
676 | **/\r | |
677 | EFI_STATUS\r | |
678 | EFIAPI\r | |
679 | AcpiFadtLibDestructor (\r | |
680 | IN CONST EFI_HANDLE ImageHandle,\r | |
681 | IN EFI_SYSTEM_TABLE * CONST SystemTable\r | |
682 | )\r | |
683 | {\r | |
684 | EFI_STATUS Status;\r | |
685 | Status = DeregisterAcpiTableGenerator (&FadtGenerator);\r | |
686 | DEBUG ((DEBUG_INFO, "FADT: Deregister Generator. Status = %r\n", Status));\r | |
687 | ASSERT_EFI_ERROR (Status);\r | |
688 | return Status;\r | |
689 | }\r |