TianoCore EDK2 master
Loading...
Searching...
No Matches
FadtGenerator.c
Go to the documentation of this file.
1
14#include <Library/AcpiLib.h>
15#include <Library/DebugLib.h>
16#include <Protocol/AcpiTable.h>
17
18// Module specific include files.
19#include <AcpiTableGenerator.h>
24#include "FadtGenerator.h"
25
56#define VALID_HARDWARE_REDUCED_FLAG_MASK ( \
57 EFI_ACPI_6_5_WBINVD | \
58 EFI_ACPI_6_5_PWR_BUTTON | \
59 EFI_ACPI_6_5_SLP_BUTTON | \
60 EFI_ACPI_6_5_FIX_RTC | \
61 EFI_ACPI_6_5_DCK_CAP | \
62 EFI_ACPI_6_5_RESET_REG_SUP | \
63 EFI_ACPI_6_5_SEALED_CASE | \
64 EFI_ACPI_6_5_HEADLESS | \
65 EFI_ACPI_6_5_USE_PLATFORM_CLOCK | \
66 EFI_ACPI_6_5_FORCE_APIC_CLUSTER_MODEL | \
67 EFI_ACPI_6_5_FORCE_APIC_PHYSICAL_DESTINATION_MODE | \
68 EFI_ACPI_6_5_HW_REDUCED_ACPI | \
69 EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE)
70
99#define VALID_NON_HARDWARE_REDUCED_FLAG_MASK ( \
100 EFI_ACPI_6_5_WBINVD | \
101 EFI_ACPI_6_5_WBINVD_FLUSH | \
102 EFI_ACPI_6_5_PROC_C1 | \
103 EFI_ACPI_6_5_P_LVL2_UP | \
104 EFI_ACPI_6_5_PWR_BUTTON | \
105 EFI_ACPI_6_5_SLP_BUTTON | \
106 EFI_ACPI_6_5_FIX_RTC | \
107 EFI_ACPI_6_5_RTC_S4 | \
108 EFI_ACPI_6_5_TMR_VAL_EXT | \
109 EFI_ACPI_6_5_DCK_CAP | \
110 EFI_ACPI_6_5_RESET_REG_SUP | \
111 EFI_ACPI_6_5_SEALED_CASE | \
112 EFI_ACPI_6_5_HEADLESS | \
113 EFI_ACPI_6_5_CPU_SW_SLP | \
114 EFI_ACPI_6_5_PCI_EXP_WAK | \
115 EFI_ACPI_6_5_USE_PLATFORM_CLOCK | \
116 EFI_ACPI_6_5_S4_RTC_STS_VALID | \
117 EFI_ACPI_6_5_REMOTE_POWER_ON_CAPABLE | \
118 EFI_ACPI_6_5_FORCE_APIC_CLUSTER_MODEL | \
119 EFI_ACPI_6_5_FORCE_APIC_PHYSICAL_DESTINATION_MODE | \
120 EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE)
121
122#pragma pack(1)
123
128STATIC
134 ),
135 // UINT32 FirmwareCtrl
136 0,
137 // UINT32 Dsdt
138 0,
139 // UINT8 Reserved0
140 EFI_ACPI_RESERVED_BYTE,
141 // UINT8 PreferredPmProfile
142 EFI_ACPI_6_5_PM_PROFILE_UNSPECIFIED, // {Template}: Power Management Profile
143 // UINT16 SciInt
144 0,
145 // UINT32 SmiCmd
146 0,
147 // UINT8 AcpiEnable
148 0,
149 // UINT8 AcpiDisable
150 0,
151 // UINT8 S4BiosReq
152 0,
153 // UINT8 PstateCnt
154 0,
155 // UINT32 Pm1aEvtBlk
156 0,
157 // UINT32 Pm1bEvtBlk
158 0,
159 // UINT32 Pm1aCntBlk
160 0,
161 // UINT32 Pm1bCntBlk
162 0,
163 // UINT32 Pm2CntBlk
164 0,
165 // UINT32 PmTmrBlk
166 0,
167 // UINT32 Gpe0Blk
168 0,
169 // UINT32 Gpe1Blk
170 0,
171 // UINT8 Pm1EvtLen
172 0,
173 // UINT8 Pm1CntLen
174 0,
175 // UINT8 Pm2CntLen
176 0,
177 // UINT8 PmTmrLen
178 0,
179 // UINT8 Gpe0BlkLen
180 0,
181 // UINT8 Gpe1BlkLen
182 0,
183 // UINT8 Gpe1Base
184 0,
185 // UINT8 CstCnt
186 0,
187 // UINT16 PLvl2Lat
188 0,
189 // UINT16 PLvl3Lat
190 0,
191 // UINT16 FlushSize
192 0,
193 // UINT16 FlushStride
194 0,
195 // UINT8 DutyOffset
196 0,
197 // UINT8 DutyWidth
198 0,
199 // UINT8 DayAlrm
200 0,
201 // UINT8 MonAlrm
202 0,
203 // UINT8 Century
204 0,
205 // UINT16 IaPcBootArch
206 0,
207 // UINT8 Reserved1
208 0,
209 // UINT32 Flags
210 0,
211 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE ResetReg
212 NULL_GAS,
213 // UINT8 ResetValue
214 0,
215 // UINT16 ArmBootArch
216 0, // {Template}: ARM Boot Architecture Flags
217 // UINT8 MinorRevision
218 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION, // {Template}
219 // UINT64 XFirmwareCtrl
220 0,
221 // UINT64 XDsdt
222 0,
223 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk
224 NULL_GAS,
225 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk
226 NULL_GAS,
227 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk
228 NULL_GAS,
229 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk
230 NULL_GAS,
231 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk
232 NULL_GAS,
233 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk
234 NULL_GAS,
235 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XGpe0Blk
236 NULL_GAS,
237 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XGpe1Blk
238 NULL_GAS,
239 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE SleepControlReg
240 NULL_GAS,
241 // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE SleepStatusReg
242 NULL_GAS,
243 // UINT64 HypervisorVendorIdentity
244 EFI_ACPI_RESERVED_QWORD // {Template}: Hypervisor Vendor ID
245};
246
247#pragma pack()
248
256 );
257
265 );
266
274 );
275
288STATIC
290EFIAPI
293 )
294{
295 EFI_STATUS Status;
297
298 ASSERT (CfgMgrProtocol != NULL);
299
300 // Get the Power Management Profile from the Platform Configuration Manager
301 Status = GetEArchCommonObjPowerManagementProfileInfo (
302 CfgMgrProtocol,
304 &PmProfile,
305 NULL
306 );
307 if (EFI_ERROR (Status)) {
308 DEBUG ((
309 DEBUG_ERROR,
310 "ERROR: FADT: Failed to get Power Management Profile information." \
311 " Status = %r\n",
312 Status
313 ));
314 goto error_handler;
315 }
316
317 DEBUG ((
318 DEBUG_INFO,
319 "FADT: PreferredPmProfile = 0x%x\n",
320 PmProfile->PowerManagementProfile
321 ));
322
323 AcpiFadt.PreferredPmProfile = PmProfile->PowerManagementProfile;
324
325error_handler:
326 return Status;
327}
328
341STATIC
343EFIAPI
346 )
347{
348 EFI_STATUS Status;
349 CM_ARCH_COMMON_HYPERVISOR_VENDOR_ID *HypervisorVendorInfo;
350
351 ASSERT (CfgMgrProtocol != NULL);
352
353 // Get the Hypervisor Vendor ID from the Platform Configuration Manager
354 Status = GetEArchCommonObjHypervisorVendorIdentity (
355 CfgMgrProtocol,
357 &HypervisorVendorInfo,
358 NULL
359 );
360 if (EFI_ERROR (Status)) {
361 if (Status == EFI_NOT_FOUND) {
362 DEBUG ((
363 DEBUG_INFO,
364 "INFO: FADT: Platform does not have a Hypervisor Vendor ID."
365 "Status = %r\n",
366 Status
367 ));
368 } else {
369 DEBUG ((
370 DEBUG_ERROR,
371 "ERROR: FADT: Failed to get Hypervisor Vendor ID. Status = %r\n",
372 Status
373 ));
374 }
375
376 goto error_handler;
377 }
378
379 DEBUG ((
380 DEBUG_INFO,
381 "FADT: EArchCommonObjHypervisorVendorIdentity = 0x%lx\n",
382 HypervisorVendorInfo->HypervisorVendorId
383 ));
384
385 AcpiFadt.HypervisorVendorIdentity = HypervisorVendorInfo->HypervisorVendorId;
386
387error_handler:
388 return Status;
389}
390
403STATIC
405EFIAPI
408 )
409{
410 EFI_STATUS Status;
411 CM_ARCH_COMMON_FIXED_FEATURE_FLAGS *FixedFeatureFlags;
412
413 ASSERT (CfgMgrProtocol != NULL);
414
415 // Get the Fixed feature flags from the Platform Configuration Manager
416 Status = GetEArchCommonObjFixedFeatureFlags (
417 CfgMgrProtocol,
419 &FixedFeatureFlags,
420 NULL
421 );
422 if (EFI_ERROR (Status)) {
423 if (Status == EFI_NOT_FOUND) {
424 DEBUG ((
425 DEBUG_INFO,
426 "INFO: FADT: Platform does not define additional Fixed feature flags."
427 "Status = %r\n",
428 Status
429 ));
430 } else {
431 DEBUG ((
432 DEBUG_ERROR,
433 "ERROR: FADT: Failed to get Fixed feature flags. Status = %r\n",
434 Status
435 ));
436 }
437
438 goto error_handler;
439 }
440
441 DEBUG ((
442 DEBUG_INFO,
443 "FADT: EArchCommonObjFixedFeatureFlags = 0x%x\n",
444 FixedFeatureFlags->Flags
445 ));
446
447 if ((FixedFeatureFlags->Flags & EFI_ACPI_6_5_HW_REDUCED_ACPI) != 0) {
448 if ((FixedFeatureFlags->Flags & ~(VALID_HARDWARE_REDUCED_FLAG_MASK)) != 0) {
449 DEBUG ((
450 DEBUG_WARN,
451 "FADT: Invalid Fixed feature flags defined by platform,"
452 "Invalid Flags bits are = 0x%x\n",
453 (FixedFeatureFlags->Flags & ~(VALID_HARDWARE_REDUCED_FLAG_MASK))
454 ));
455 }
456
457 AcpiFadt.Flags |= (FixedFeatureFlags->Flags &
459 } else {
460 if ((FixedFeatureFlags->Flags & ~(VALID_NON_HARDWARE_REDUCED_FLAG_MASK)) != 0) {
461 DEBUG ((
462 DEBUG_WARN,
463 "FADT: Invalid Fixed feature flags defined for non-hardware reduced model,"
464 "Invalid Flags bits are = 0x%x\n",
465 (FixedFeatureFlags->Flags & ~(VALID_NON_HARDWARE_REDUCED_FLAG_MASK))
466 ));
467 }
468
469 AcpiFadt.Flags |= (FixedFeatureFlags->Flags &
471 }
472
473error_handler:
474 return Status;
475}
476
499STATIC
501EFIAPI
507 )
508{
509 EFI_STATUS Status;
510
511 ASSERT (This != NULL);
512 ASSERT (AcpiTableInfo != NULL);
513 ASSERT (CfgMgrProtocol != NULL);
514 ASSERT (Table != NULL);
515 ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
516 ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
517
518 if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) ||
519 (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision))
520 {
521 DEBUG ((
522 DEBUG_ERROR,
523 "ERROR: FADT: Requested table revision = %d, is not supported."
524 "Supported table revision: Minimum = %d, Maximum = %d\n",
525 AcpiTableInfo->AcpiTableRevision,
526 This->MinAcpiTableRevision,
527 This->AcpiTableRevision
528 ));
529 return EFI_INVALID_PARAMETER;
530 }
531
532 *Table = NULL;
533
534 Status = AddAcpiHeader (
535 CfgMgrProtocol,
536 This,
538 AcpiTableInfo,
540 );
541 if (EFI_ERROR (Status)) {
542 DEBUG ((
543 DEBUG_ERROR,
544 "ERROR: FADT: Failed to add ACPI header. Status = %r\n",
545 Status
546 ));
547 goto error_handler;
548 }
549
550 // Update the MinorRevision for the FADT table if it has been specified
551 // otherwise default to the latest FADT minor revision supported.
552 // Note:
553 // Bits 0-3 - The low order bits correspond to the minor version of the
554 // specification version.
555 // Bits 4-7 - The high order bits correspond to the version of the ACPI
556 // specification errata.
557 if (AcpiTableInfo->MinorRevision != 0) {
558 if (((AcpiTableInfo->MinorRevision & 0xF) >=
559 EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION) &&
560 ((AcpiTableInfo->MinorRevision & 0xF) <=
561 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION))
562 {
563 AcpiFadt.MinorVersion = AcpiTableInfo->MinorRevision;
564 } else {
565 DEBUG ((
566 DEBUG_WARN,
567 "WARNING: FADT: Unsupported FADT Minor Revision 0x%x specified, " \
568 "defaulting to FADT Minor Revision 0x%x\n",
569 AcpiTableInfo->MinorRevision,
570 EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION
571 ));
572 }
573 }
574
575 // Update PmProfile Info
576 Status = FadtAddPmProfileInfo (CfgMgrProtocol);
577 if (EFI_ERROR (Status)) {
578 goto error_handler;
579 }
580
581 // Add the Hypervisor Vendor Id if present
582 // Note if no hypervisor is present the zero bytes
583 // will be placed in this field.
584 Status = FadtAddHypervisorVendorId (CfgMgrProtocol);
585 if (EFI_ERROR (Status)) {
586 if (Status == EFI_NOT_FOUND) {
587 DEBUG ((
588 DEBUG_INFO,
589 "INFO: FADT: No Hypervisor Vendor ID found," \
590 " assuming no Hypervisor is present in the firmware.\n"
591 ));
592 } else {
593 DEBUG ((
594 DEBUG_ERROR,
595 "ERROR: FADT: Error reading Hypervisor Vendor ID, Status = %r",
596 Status
597 ));
598 goto error_handler;
599 }
600 }
601
602 Status = FadtAddFixedFeatureFlags (CfgMgrProtocol);
603 if (EFI_ERROR (Status)) {
604 if (Status == EFI_NOT_FOUND) {
605 DEBUG ((
606 DEBUG_INFO,
607 "INFO: FADT: No Fixed feature flags found," \
608 " assuming no additional flags are defined for the platform.\n"
609 ));
610 Status = EFI_SUCCESS;
611 } else {
612 DEBUG ((
613 DEBUG_ERROR,
614 "ERROR: FADT: Error reading Fixed feature flags, Status = %r",
615 Status
616 ));
617 goto error_handler;
618 }
619 }
620
621 // Update Arch specific Info
622 Status = FadtArchUpdate (CfgMgrProtocol, &AcpiFadt);
623 if (EFI_ERROR (Status)) {
624 goto error_handler;
625 }
626
628error_handler:
629 return Status;
630}
631
634#define FADT_GENERATOR_REVISION CREATE_REVISION (1, 0)
635
638STATIC
639CONST
641 // Generator ID
643 // Generator Description
644 L"ACPI.STD.FADT.GENERATOR",
645 // ACPI Table Signature
647 // ACPI Table Revision supported by this Generator
649 // Minimum supported ACPI Table Revision
651 // Creator ID
653 // Creator Revision
655 // Build Table function
657 // No additional resources are allocated by the generator.
658 // Hence the Free Resource function is not required.
659 NULL,
660 // Extended build function not needed
661 NULL,
662 // Extended build function not implemented by the generator.
663 // Hence extended free resource function is not required.
664 NULL
665};
666
678EFIAPI
680 IN EFI_HANDLE ImageHandle,
681 IN EFI_SYSTEM_TABLE *SystemTable
682 )
683{
684 EFI_STATUS Status;
685
687 DEBUG ((DEBUG_INFO, "FADT: Register Generator. Status = %r\n", Status));
688 ASSERT_EFI_ERROR (Status);
689 return Status;
690}
691
702EFIAPI
704 IN EFI_HANDLE ImageHandle,
705 IN EFI_SYSTEM_TABLE *SystemTable
706 )
707{
708 EFI_STATUS Status;
709
711 DEBUG ((DEBUG_INFO, "FADT: Deregister Generator. Status = %r\n", Status));
712 ASSERT_EFI_ERROR (Status);
713 return Status;
714}
#define EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
Definition: Acpi62.h:278
#define EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
Definition: Acpi65.h:188
#define EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
Definition: Acpi65.h:3082
EFI_STATUS EFIAPI RegisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
EFI_STATUS EFIAPI DeregisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
#define CREATE_STD_ACPI_TABLE_GEN_ID(TableId)
#define TABLE_GENERATOR_CREATOR_ID
@ EStdAcpiTableIdFadt
FADT Generator.
#define ACPI_HEADER(Signature, Type, Revision)
@ EArchCommonObjPowerManagementProfileInfo
1 - Power Management Profile Info
@ EArchCommonObjHypervisorVendorIdentity
5 - Hypervisor Vendor Id
@ EArchCommonObjFixedFeatureFlags
6 - Fixed feature flags for FADT
EFI_STATUS EFIAPI FadtArchUpdate(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt)
#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)
@ EObjNameSpaceArchCommon
Arch Common Objects Namespace.
#define VALID_HARDWARE_REDUCED_FLAG_MASK
Definition: FadtGenerator.c:56
#define VALID_NON_HARDWARE_REDUCED_FLAG_MASK
Definition: FadtGenerator.c:99
#define FADT_GENERATOR_REVISION
STATIC EFI_STATUS EFIAPI FadtAddPmProfileInfo(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol)
STATIC CONST ACPI_TABLE_GENERATOR FadtGenerator
STATIC EFI_STATUS EFIAPI BuildFadtTable(IN CONST ACPI_TABLE_GENERATOR *CONST This, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table)
EFI_STATUS EFIAPI AcpiFadtLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE AcpiFadt
EFI_STATUS EFIAPI AcpiFadtLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC EFI_STATUS EFIAPI FadtAddHypervisorVendorId(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol)
STATIC EFI_STATUS EFIAPI FadtAddFixedFeatureFlags(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define CM_NULL_TOKEN
EFI_STATUS EFIAPI AddAcpiHeader(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST ACPI_TABLE_GENERATOR *CONST Generator, IN OUT EFI_ACPI_DESCRIPTION_HEADER *CONST AcpiHeader, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST UINT32 Length)
Definition: TableHelper.c:114
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
UINT32 Flags
The Fixed feature flags.
UINT64 HypervisorVendorId
The hypervisor Vendor ID.