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