DynamicTablesPkg: AcpiFadtLib: Prepare to support other archs

Allow other architectures to reuse the AcpiFadtLib by extracting
the Arm specific part of the table generation.

Suggested-by: Sunil V L <sunilvl@ventanamicro.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
Pierre Gondois 2024-06-10 14:00:00 +02:00 committed by mergify[bot]
parent b242de55e2
commit e69e1eea2c
5 changed files with 225 additions and 76 deletions

View File

@ -18,6 +18,13 @@
[Sources]
FadtGenerator.c
FadtGenerator.h
[Sources.ARM, Sources.AARCH64]
Arm/ArmFadtGenerator.c
[Sources.IA32, Sources.X64]
FadtGeneratorNull.c
[Packages]
MdePkg/MdePkg.dec

View File

@ -0,0 +1,126 @@
/** @file
ARM FADT Table Helpers
Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Reference(s):
- ACPI 6.5 Specification, Aug 29, 2022
**/
#include <Library/AcpiLib.h>
#include <Library/DebugLib.h>
#include <Protocol/AcpiTable.h>
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
#include "FadtGenerator.h"
/** ARM Standard FADT Generator
Requirements:
The following Configuration Manager Object(s) are required by
this Generator:
- EArmObjBootArchInfo
*/
/** This macro expands to a function that retrieves the Boot
Architecture Information from the Configuration Manager.
*/
GET_OBJECT_LIST (
EObjNameSpaceArm,
EArmObjBootArchInfo,
CM_ARM_BOOT_ARCH_INFO
);
/** This macro defines the FADT flag options for ARM Platforms.
*/
#define FADT_FLAGS (EFI_ACPI_6_5_HW_REDUCED_ACPI | \
EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE)
/** Updates the Architecture specific information in the FADT Table.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol Interface.
@param [in, out] Fadt Pointer to the constructed ACPI Table.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_NOT_FOUND The required object was not found.
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
Manager is less than the Object size for the
requested object.
**/
STATIC
EFI_STATUS
EFIAPI
ArmFadtBootArchInfoUpdate (
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt
)
{
EFI_STATUS Status;
CM_ARM_BOOT_ARCH_INFO *BootArchInfo;
ASSERT (CfgMgrProtocol != NULL);
ASSERT (Fadt != NULL);
// Get the Boot Architecture flags from the Platform Configuration Manager
Status = GetEArmObjBootArchInfo (
CfgMgrProtocol,
CM_NULL_TOKEN,
&BootArchInfo,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ERROR: FADT: Failed to get Boot Architecture flags. Status = %r\n",
Status
));
return Status;
}
DEBUG ((
DEBUG_INFO,
"FADT BootArchFlag = 0x%x\n",
BootArchInfo->BootArchFlags
));
Fadt->ArmBootArch = BootArchInfo->BootArchFlags;
return Status;
}
/** Updates the Architecture specific information in the FADT Table.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol Interface.
@param [in, out] Fadt Pointer to the constructed ACPI Table.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_NOT_FOUND The required object was not found.
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
Manager is less than the Object size for the
requested object.
**/
EFI_STATUS
EFIAPI
FadtArchUpdate (
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt
)
{
ASSERT (CfgMgrProtocol != NULL);
ASSERT (Fadt != NULL);
Fadt->Flags = FADT_FLAGS;
return ArmFadtBootArchInfoUpdate (CfgMgrProtocol, Fadt);
}

View File

@ -19,22 +19,17 @@
#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
#include "FadtGenerator.h"
/** ARM standard FADT Generator
/** Standard FADT Generator
Requirements:
The following Configuration Manager Object(s) are required by
this Generator:
- EArchCommonObjPowerManagementProfileInfo
- EArmObjBootArchInfo
- EArchCommonObjHypervisorVendorIdentity (OPTIONAL)
*/
/** This macro defines the FADT flag options for ARM Platforms.
*/
#define FADT_FLAGS (EFI_ACPI_6_5_HW_REDUCED_ACPI | \
EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE)
/** This macro defines the valid mask for the FADT flag option
if HW_REDUCED_ACPI flag in the table is set.
@ -159,13 +154,13 @@ EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE AcpiFadt = {
// UINT8 Reserved1
0,
// UINT32 Flags
FADT_FLAGS,
0,
// EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE ResetReg
NULL_GAS,
// UINT8 ResetValue
0,
// UINT16 ArmBootArch
EFI_ACPI_6_5_ARM_PSCI_COMPLIANT, // {Template}: ARM Boot Architecture Flags
0, // {Template}: ARM Boot Architecture Flags
// UINT8 MinorRevision
EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION, // {Template}
// UINT64 XFirmwareCtrl
@ -207,15 +202,6 @@ GET_OBJECT_LIST (
CM_ARCH_COMMON_POWER_MANAGEMENT_PROFILE_INFO
);
/** This macro expands to a function that retrieves the Boot
Architecture Information from the Configuration Manager.
*/
GET_OBJECT_LIST (
EObjNameSpaceArm,
EArmObjBootArchInfo,
CM_ARM_BOOT_ARCH_INFO
);
/** This macro expands to a function that retrieves the Hypervisor
Vendor ID from the Configuration Manager.
*/
@ -287,58 +273,6 @@ error_handler:
return Status;
}
/** Updates the Boot Architecture information in the FADT Table.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol Interface.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_NOT_FOUND The required object was not found.
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
Manager is less than the Object size for the
requested object.
**/
STATIC
EFI_STATUS
EFIAPI
FadtAddBootArchInfo (
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol
)
{
EFI_STATUS Status;
CM_ARM_BOOT_ARCH_INFO *BootArchInfo;
ASSERT (CfgMgrProtocol != NULL);
// Get the Boot Architecture flags from the Platform Configuration Manager
Status = GetEArmObjBootArchInfo (
CfgMgrProtocol,
CM_NULL_TOKEN,
&BootArchInfo,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ERROR: FADT: Failed to get Boot Architecture flags. Status = %r\n",
Status
));
goto error_handler;
}
DEBUG ((
DEBUG_INFO,
"FADT BootArchFlag = 0x%x\n",
BootArchInfo->BootArchFlags
));
AcpiFadt.ArmBootArch = BootArchInfo->BootArchFlags;
error_handler:
return Status;
}
/** Update the Hypervisor Vendor ID in the FADT Table.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
@ -577,12 +511,6 @@ BuildFadtTable (
goto error_handler;
}
// Update BootArch Info
Status = FadtAddBootArchInfo (CfgMgrProtocol);
if (EFI_ERROR (Status)) {
goto error_handler;
}
// Add the Hypervisor Vendor Id if present
// Note if no hypervisor is present the zero bytes
// will be placed in this field.
@ -623,6 +551,12 @@ BuildFadtTable (
}
}
// Update Arch specific Info
Status = FadtArchUpdate (CfgMgrProtocol, &AcpiFadt);
if (EFI_ERROR (Status)) {
goto error_handler;
}
*Table = (EFI_ACPI_DESCRIPTION_HEADER *)&AcpiFadt;
error_handler:
return Status;

View File

@ -0,0 +1,35 @@
/** @file
FADT Table Generator
Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Reference(s):
- ACPI 6.5 Specification, Aug 29, 2022
**/
#ifndef FADT_GENERATOR_H_
#define FADT_GENERATOR_H_
/** Updates the Architecture specific information in the FADT Table.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol Interface.
@param [in, out] Fadt Pointer to the constructed ACPI Table.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_NOT_FOUND The required object was not found.
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
Manager is less than the Object size for the
requested object.
**/
EFI_STATUS
EFIAPI
FadtArchUpdate (
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt
);
#endif // FADT_GENERATOR_H_

View File

@ -0,0 +1,47 @@
/** @file
Common FADT Table Helpers
Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Reference(s):
- ACPI 6.5 Specification, Aug 29, 2022
**/
#include <Library/AcpiLib.h>
#include <Library/DebugLib.h>
#include <Protocol/AcpiTable.h>
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
#include "FadtGenerator.h"
/** Updates the Architecture specific information in the FADT Table.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol Interface.
@param [in, out] Fadt Pointer to the constructed ACPI Table.
@retval EFI_SUCCESS Success.
@retval EFI_UNSUPPORTED Unsupported.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_NOT_FOUND The required object was not found.
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
Manager is less than the Object size for the
requested object.
**/
EFI_STATUS
EFIAPI
FadtArchUpdate (
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt
)
{
// Not implemented.
return EFI_UNSUPPORTED;
}