From f6d56a3393600b0bb7e72fd465dd1daf34fd4c5f Mon Sep 17 00:00:00 2001 From: Abdul Lateef Attar Date: Mon, 7 Oct 2024 07:44:40 +0000 Subject: [PATCH] AmdPlatformPkg: Add Configuration manager driver Adds configuration manager driver for AMD platform. This driver provides configuration information to the ACPI or SMBIOS generator libraries. --- .../ConfigurationManager.c | 228 ++++++ .../ConfigurationManager.h | 103 +++ .../ConfigurationManagerDxe.inf | 53 ++ .../ConfigurationManagerDxe/NameSpaceObject.c | 736 ++++++++++++++++++ 4 files changed, 1120 insertions(+) create mode 100755 Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c create mode 100755 Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.h create mode 100755 Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManagerDxe.inf create mode 100644 Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c new file mode 100755 index 0000000000..219512edb0 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c @@ -0,0 +1,228 @@ +/** @file + Configuration Manager Protocol implementation for AMD platform. + This file implements the Configuration Manager Protocol for the AMD platform. + The Configuration Manager Protocol is used to provide the Configuration + Objects to the Configuration Manager. + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include "ConfigurationManager.h" + +/** The platform configuration repository information. +*/ +STATIC +EDKII_PLATFORM_REPOSITORY_INFO mAmdPlatformRepositoryInfo = { + /// Configuration Manager Information + { + CONFIGURATION_MANAGER_REVISION, + CFG_MGR_OEM_ID + }, + /// ACPI Table List + { + /// FADT Table + { + EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_REVISION, + CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt), + NULL + }, + /// HPET Table + { + EFI_ACPI_6_3_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE, + EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_REVISION, + CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdHpet), + NULL + }, + /// HPET Ssdt Table + { + EFI_ACPI_6_5_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + 0, // Unused + CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSsdtHpet), + NULL + }, + /// WSMT Table + { + EFI_ACPI_6_3_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE, + EFI_WSMT_TABLE_REVISION, + CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdWsmt), + NULL + }, + /// SPMI Table + { + EFI_ACPI_6_5_SERVER_PLATFORM_MANAGEMENT_INTERFACE_TABLE_SIGNATURE, + EFI_ACPI_SERVICE_PROCESSOR_MANAGEMENT_INTERFACE_5_TABLE_REVISION, + CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSpmi), + NULL + }, + }, + /// PmProfile + { + EFI_ACPI_6_5_PM_PROFILE_ENTERPRISE_SERVER + }, + /// HypervisorVendorId + { + 0x00000000 + }, + /// FixedFeatureFlags + { + EFI_ACPI_6_5_WBINVD | \ + EFI_ACPI_6_5_PROC_C1 | \ + EFI_ACPI_6_5_P_LVL2_UP | \ + EFI_ACPI_6_5_SLP_BUTTON | \ + EFI_ACPI_6_5_TMR_VAL_EXT | \ + EFI_ACPI_6_5_RESET_REG_SUP | \ + EFI_ACPI_6_5_REMOTE_POWER_ON_CAPABLE + }, + /// SciInterrupt + { + 0x0009 + }, + /// SciCmdinfo + { + 0x000000B2, + 0xA0, + 0xA1, + 0x00, + 0x00, + 0x00 + }, + /// PmBlockInfo + { + 0x00000800, + 0x00000000, + 0x00000804, + 0x00000000, + 0x00000000, + 0x00000808, + 0x04, + 0x02, + 0x00, + 0x04 + }, + /// GPE block + { + 0x00000820, + 0x00000000, + 0x08, + 0x00, + 0x00 + }, + /// X PM Event + { + { EFI_ACPI_6_5_SYSTEM_IO, 0x20, 0x0, EFI_ACPI_6_5_WORD, 0x0000000000000800 }, + { 0x0, 0x0, 0x0, 0x0, 0x0000000000000000 }, + { EFI_ACPI_6_5_SYSTEM_IO, 0x10, 0x0, EFI_ACPI_6_5_WORD, 0x0000000000000804 }, + { 0x0, 0x0, 0x0, 0x0, 0x0000000000000000 }, + { 0x0, 0x0, 0x0, 0x0, 0x0000000000000000 }, + { EFI_ACPI_6_5_SYSTEM_IO, 0x20, 0x0, EFI_ACPI_6_5_DWORD, 0x0000000000000808 } + }, + /// X GPE Event + { + { EFI_ACPI_6_5_SYSTEM_IO, 0x40, 0x0, EFI_ACPI_6_5_BYTE, 0x0000000000000820 }, + { 0x0, 0x0, 0x0, 0x0, 0x0000000000000000 } + }, + /// Sleep Event + { + { 0x0, 0x0, 0x0, 0x0, 0x0 }, + { 0x0, 0x0, 0x0, 0x0, 0x0 } + }, + /// Reset Event + { + { EFI_ACPI_6_5_SYSTEM_IO, 0x8, 0x0, EFI_ACPI_6_5_UNDEFINED, 0x0000000000000CF9 }, + 0x06 + }, + /// FadtMiscInfo + { + 0x0064, + 0x03E9, + 0x0400, + 0x0010, + 0x01, + 0x03, + 0x0D, + 0x00, + 0x32 + }, + /// HpetInfo + { + FixedPcdGet64 (PcdHpetBaseAddress), + 0x37EE, + 0x0 + }, + /// Wsmt flags info + { + EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS | \ + EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION | \ + EFI_WSMT_PROTECTION_FLAGS_SYSTEM_RESOURCE_PROTECTION + }, + /// SpmiInterruptInfo + { + 0x01, + { EFI_ACPI_6_5_SYSTEM_IO, 0x8, 0, 0, 0x0000000000000CA2 } + } +}; + +/** A structure describing the configuration manager protocol interface. +*/ +STATIC +CONST +EDKII_CONFIGURATION_MANAGER_PROTOCOL mAmdPlatformConfigManagerProtocol = { + CREATE_REVISION (1, 0), + AmdPlatformGetObject, + AmdPlatformSetObject, + &mAmdPlatformRepositoryInfo +}; + +/** + Entrypoint of Configuration Manager Dxe. + + @param [in] ImageHandle + @param [in] SystemTable + + @return EFI_SUCCESS + @return EFI_LOAD_ERROR + @return EFI_OUT_OF_RESOURCES +**/ +EFI_STATUS +EFIAPI +ConfigurationManagerDxeInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + UINTN Index; + + /// set the OemTableId and OemRevision for the CmACpiTableList + for (Index = 0; Index < ARRAY_SIZE (mAmdPlatformRepositoryInfo.CmAcpiTableList); Index++) { + mAmdPlatformRepositoryInfo.CmAcpiTableList[Index].OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId); + mAmdPlatformRepositoryInfo.CmAcpiTableList[Index].OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision); + } + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gEdkiiConfigurationManagerProtocolGuid, + EFI_NATIVE_INTERFACE, + (VOID *)&mAmdPlatformConfigManagerProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to get Install Configuration Manager Protocol." \ + " Status = %r\n", + Status + )); + } + + return Status; +} diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.h b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.h new file mode 100755 index 0000000000..b4c3b21588 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.h @@ -0,0 +1,103 @@ +/** @file + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Cm or CM - Configuration Manager + - Obj or OBJ - Object +**/ + +#ifndef CONFIGURATION_MANAGER_H_ +#define CONFIGURATION_MANAGER_H_ + +#include +#include +#include + +/** The number of ACPI tables to install +*/ +#define PLAT_ACPI_TABLE_COUNT 5 + +/** The configuration manager version. +*/ +#define CONFIGURATION_MANAGER_REVISION CREATE_REVISION (1, 0) + +/** The OEM ID +*/ +#define CFG_MGR_OEM_ID { 'A', 'M', 'D', 'I', 'N', 'C' } + +/** A structure describing the platform configuration + manager repository information +*/ +typedef struct PlatformRepositoryInfo { + /// Configuration Manager Information + CM_STD_OBJ_CONFIGURATION_MANAGER_INFO CmInfo; + + /// List of ACPI tables + CM_STD_OBJ_ACPI_TABLE_INFO CmAcpiTableList[PLAT_ACPI_TABLE_COUNT]; + CM_ARCH_COMMON_POWER_MANAGEMENT_PROFILE_INFO PowerManagementProfile; + CM_ARCH_COMMON_HYPERVISOR_VENDOR_ID HypervisorVendorId; + CM_ARCH_COMMON_FIXED_FEATURE_FLAGS FixedFeatureFlags; + CM_X64_FADT_SCI_INTERRUPT SciInterrupt; + CM_X64_FADT_SCI_CMD_INFO SciCmdinfo; + CM_X64_FADT_PM_BLOCK_INFO PmBlockInfo; + CM_X64_FADT_GPE_BLOCK_INFO GpeBlockInfo; + CM_X64_FADT_X_PM_BLOCK_INFO XpmBlockInfo; + CM_X64_FADT_X_GPE_BLOCK_INFO XgpeBlockInfo; + CM_X64_FADT_SLEEP_BLOCK_INFO SleepBlockInfo; + CM_X64_FADT_RESET_BLOCK_INFO ResetBlockInfo; + CM_X64_FADT_MISC_INFO FadtMiscInfo; + CM_X64_HPET_INFO HpetInfo; + CM_X64_WSMT_FLAGS_INFO WsmtFlagsInfo; + CM_ARCH_COMMON_SPMI_INTERFACE_INFO SpmiInterfaceInfo; +} EDKII_PLATFORM_REPOSITORY_INFO; + +/** The SetObject function defines the interface implemented by the + Configuration Manager Protocol for updating the Configuration + Manager Objects. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token An optional token identifying the object. If + unused this must be CM_NULL_TOKEN. + @param [in] CmObject Pointer to the Configuration Manager Object + descriptor describing the Object. + + @retval EFI_UNSUPPORTED This operation is not supported. +**/ +EFI_STATUS +EFIAPI +AmdPlatformSetObject ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN CM_OBJ_DESCRIPTOR *CONST CmObject + ); + +/** The GetObject function defines the interface implemented by the + Configuration Manager Protocol for returning the Configuration + Manager Objects. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token An optional token identifying the object. If + unused this must be CM_NULL_TOKEN. + @param [in, out] CmObject Pointer to the Configuration Manager Object + descriptor describing the requested Object. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. +**/ +EFI_STATUS +EFIAPI +AmdPlatformGetObject ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject + ); + +#endif // CONFIGURATION_MANAGER_H_ diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManagerDxe.inf b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManagerDxe.inf new file mode 100755 index 0000000000..cf37ebaa45 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManagerDxe.inf @@ -0,0 +1,53 @@ +## @file +# AMD platform configuration manager Dxe driver. +# +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 1.30 + BASE_NAME = ConfigurationManagerDxe + FILE_GUID = C0400631-702B-4E7D-9CC1-38F0BD021F5D + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = ConfigurationManagerDxeInitialize + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = X64 +# + +[Sources] + ConfigurationManager.c + NameSpaceObject.c + ConfigurationManager.h + +[Packages] + AmdPlatformPkg/AmdPlatformPkg.dec + DynamicTablesPkg/DynamicTablesPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + PcAtChipsetPkg/PcAtChipsetPkg.dec + +[LibraryClasses] + DebugLib + PrintLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiRuntimeServicesTableLib + +[Protocols] + gEdkiiConfigurationManagerProtocolGuid + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId + gPcAtChipsetPkgTokenSpaceGuid.PcdHpetBaseAddress + +[Depex] + TRUE diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c new file mode 100644 index 0000000000..13ceba0860 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c @@ -0,0 +1,736 @@ +/** @file + This file implements the Get/Set function for the Configuration Manager. + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include +#include +#include +#include +#include +#include "ConfigurationManager.h" + +/** A helper function for returning the Configuration Manager Objects. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Object Pointer to the Object(s). + @param [in] ObjectSize Total size of the Object(s). + @param [in] ObjectCount Number of Objects. + @param [in, out] CmObjectDesc Pointer to the Configuration Manager Object + descriptor describing the requested Object. + @retval EFI_SUCCESS Success. +**/ +STATIC +EFI_STATUS +EFIAPI +HandleCmObject ( + IN CONST CM_OBJECT_ID CmObjectId, + IN VOID *Object, + IN CONST UINTN ObjectSize, + IN CONST UINTN ObjectCount, + IN OUT CM_OBJ_DESCRIPTOR *CONST CmObjectDesc + ) +{ + CmObjectDesc->ObjectId = CmObjectId; + CmObjectDesc->Size = (UINT32)ObjectSize; + CmObjectDesc->Data = (VOID *)Object; + CmObjectDesc->Count = (UINT32)ObjectCount; + DEBUG (( + DEBUG_INFO, + "INFO: CmObjectId = %x, Ptr = 0x%p, Size = %d, Count = %d\n", + CmObjectId, + CmObjectDesc->Data, + CmObjectDesc->Size, + CmObjectDesc->Count + )); + return EFI_SUCCESS; +} + +/** A helper function for setting the Configuration Manager Objects. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [out] Object Pointer to the Object(s). + @param [in] ObjectSize Total size of the Object(s). + @param [in] ObjectCount Number of Objects. + @param [in] CmObjectDesc Pointer to the Configuration Manager Object + descriptor describing the requested Object. + @retval EFI_SUCCESS Success. +**/ +STATIC +EFI_STATUS +EFIAPI +SetHandleCmObject ( + IN CONST CM_OBJECT_ID CmObjectId, + OUT VOID *Object, + IN CONST UINTN ObjectSize, + IN CONST UINTN ObjectCount, + IN CM_OBJ_DESCRIPTOR *CONST CmObjectDesc + ) +{ + DEBUG (( + DEBUG_INFO, + "INFO: Received CmObjectId = %x, Ptr = 0x%p, Size = %d, Count = %d\n", + CmObjectId, + CmObjectDesc->Data, + CmObjectDesc->Size, + CmObjectDesc->Count + )); + if ((CmObjectDesc->Size != ObjectSize) || (CmObjectDesc->Count != ObjectCount)) { + return EFI_BAD_BUFFER_SIZE; + } + + CopyMem (Object, CmObjectDesc->Data, (ObjectSize * ObjectCount)); + + return EFI_SUCCESS; +} + +/** Return a standard namespace object. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token An optional token identifying the object. If + unused this must be CM_NULL_TOKEN. + @param [in, out] CmObject Pointer to the Configuration Manager Object + descriptor describing the requested Object. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. +**/ +EFI_STATUS +EFIAPI +GetStandardNameSpaceObject ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject + ) +{ + EFI_STATUS Status; + EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo; + UINT32 AcpiTableCount; + + if ((This == NULL) || (CmObject == NULL)) { + ASSERT (This != NULL); + ASSERT (CmObject != NULL); + return EFI_INVALID_PARAMETER; + } + + Status = EFI_NOT_FOUND; + PlatformRepo = This->PlatRepoInfo; + AcpiTableCount = ARRAY_SIZE (PlatformRepo->CmAcpiTableList); + + switch (GET_CM_OBJECT_ID (CmObjectId)) { + case EStdObjCfgMgrInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->CmInfo, + sizeof (PlatformRepo->CmInfo), + 1, + CmObject + ); + break; + case EStdObjAcpiTableList: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->CmAcpiTableList, + sizeof (PlatformRepo->CmAcpiTableList), + AcpiTableCount, + CmObject + ); + break; + default: + { + Status = EFI_NOT_FOUND; + DEBUG (( + DEBUG_ERROR, + "ERROR: Object 0x%x. Status = %r\n", + CmObjectId, + Status + )); + break; + } + } + + return Status; +} + +/** Return an architecture namespace object. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token An optional token identifying the object. If + unused this must be CM_NULL_TOKEN. + @param [in, out] CmObject Pointer to the Configuration Manager Object + descriptor describing the requested Object. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. +**/ +EFI_STATUS +EFIAPI +GetArchNameSpaceObject ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject + ) +{ + EFI_STATUS Status; + EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo; + + if ((This == NULL) || (CmObject == NULL)) { + ASSERT (This != NULL); + ASSERT (CmObject != NULL); + return EFI_INVALID_PARAMETER; + } + + Status = EFI_NOT_FOUND; + PlatformRepo = This->PlatRepoInfo; + + switch (GET_CM_OBJECT_ID (CmObjectId)) { + case EArchCommonObjPowerManagementProfileInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->PowerManagementProfile, + sizeof (PlatformRepo->PowerManagementProfile), + 1, + CmObject + ); + break; + + case EArchCommonObjHypervisorVendorIdentity: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->HypervisorVendorId, + sizeof (PlatformRepo->HypervisorVendorId), + 1, + CmObject + ); + break; + + case EArchCommonObjFixedFeatureFlags: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->FixedFeatureFlags, + sizeof (PlatformRepo->FixedFeatureFlags), + 1, + CmObject + ); + break; + + case EArchCommonObjSpmiInterfaceInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->SpmiInterfaceInfo, + sizeof (PlatformRepo->SpmiInterfaceInfo), + 1, + CmObject + ); + break; + default: + { + Status = EFI_NOT_FOUND; + DEBUG (( + DEBUG_ERROR, + "ERROR: Object 0x%x. Status = %r\n", + CmObjectId, + Status + )); + break; + } + } + + return Status; +} + +/** Set the data for an architecture namespace object. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token An optional token identifying the object. If + unused this must be CM_NULL_TOKEN. + @param [in] CmObject Pointer to the Configuration Manager Object + descriptor describing the requested Object. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. +**/ +EFI_STATUS +EFIAPI +SetArchNameSpaceObject ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN CM_OBJ_DESCRIPTOR *CONST CmObject + ) +{ + EFI_STATUS Status; + EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo; + + if ((This == NULL) || (CmObject == NULL)) { + ASSERT (This != NULL); + ASSERT (CmObject != NULL); + return EFI_INVALID_PARAMETER; + } + + Status = EFI_NOT_FOUND; + PlatformRepo = This->PlatRepoInfo; + + switch (GET_CM_OBJECT_ID (CmObjectId)) { + case EArchCommonObjPowerManagementProfileInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->PowerManagementProfile, + sizeof (PlatformRepo->PowerManagementProfile), + 1, + CmObject + ); + break; + + case EArchCommonObjHypervisorVendorIdentity: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->HypervisorVendorId, + sizeof (PlatformRepo->HypervisorVendorId), + 1, + CmObject + ); + break; + + case EArchCommonObjFixedFeatureFlags: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->FixedFeatureFlags, + sizeof (PlatformRepo->FixedFeatureFlags), + 1, + CmObject + ); + break; + default: + { + Status = EFI_NOT_FOUND; + DEBUG (( + DEBUG_ERROR, + "ERROR: Object 0x%x. Status = %r\n", + CmObjectId, + Status + )); + break; + } + } + + return Status; +} + +/** Return an architecture namespace object. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token An optional token identifying the object. If + unused this must be CM_NULL_TOKEN. + @param [in, out] CmObject Pointer to the Configuration Manager Object + descriptor describing the requested Object. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. +**/ +EFI_STATUS +EFIAPI +GetX64NameSpaceObject ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject + ) +{ + EFI_STATUS Status; + EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo; + + if ((This == NULL) || (CmObject == NULL)) { + ASSERT (This != NULL); + ASSERT (CmObject != NULL); + return EFI_INVALID_PARAMETER; + } + + Status = EFI_NOT_FOUND; + PlatformRepo = This->PlatRepoInfo; + + switch (GET_CM_OBJECT_ID (CmObjectId)) { + case EX64ObjFadtSciInterrupt: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->SciInterrupt, + sizeof (PlatformRepo->SciInterrupt), + 1, + CmObject + ); + break; + case EX64ObjFadtSciCmdInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->SciCmdinfo, + sizeof (PlatformRepo->SciCmdinfo), + 1, + CmObject + ); + break; + case EX64ObjFadtPmBlockInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->PmBlockInfo, + sizeof (PlatformRepo->PmBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtGpeBlockInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->GpeBlockInfo, + sizeof (PlatformRepo->GpeBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtXpmBlockInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->XpmBlockInfo, + sizeof (PlatformRepo->XpmBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtXgpeBlockInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->XgpeBlockInfo, + sizeof (PlatformRepo->XgpeBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtSleepBlockInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->SleepBlockInfo, + sizeof (PlatformRepo->SleepBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtResetBlockInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->ResetBlockInfo, + sizeof (PlatformRepo->ResetBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtMiscInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->FadtMiscInfo, + sizeof (PlatformRepo->FadtMiscInfo), + 1, + CmObject + ); + break; + case EX64ObjHpetInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->HpetInfo, + sizeof (PlatformRepo->HpetInfo), + 1, + CmObject + ); + break; + case EX64ObjWsmtFlagsInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->WsmtFlagsInfo, + sizeof (PlatformRepo->WsmtFlagsInfo), + 1, + CmObject + ); + break; + default: + { + Status = EFI_NOT_FOUND; + DEBUG (( + DEBUG_ERROR, + "ERROR: Object 0x%x. Status = %r\n", + CmObjectId, + Status + )); + break; + } + } + + return Status; +} + +/** + Set the data for X64 namespace object. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token An optional token identifying the object. + If unused this must be CM_NULL_TOKEN. + @param [in] CmObject Pointer to the Configuration Manager Object. +**/ +EFI_STATUS +EFIAPI +SetX64NameSpaceObject ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN CM_OBJ_DESCRIPTOR *CONST CmObject + ) +{ + EFI_STATUS Status; + EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo; + + if ((This == NULL) || (CmObject == NULL)) { + ASSERT (This != NULL); + ASSERT (CmObject != NULL); + return EFI_INVALID_PARAMETER; + } + + Status = EFI_NOT_FOUND; + PlatformRepo = This->PlatRepoInfo; + + switch (GET_CM_OBJECT_ID (CmObjectId)) { + case EX64ObjFadtSciInterrupt: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->SciInterrupt, + sizeof (PlatformRepo->SciInterrupt), + 1, + CmObject + ); + break; + case EX64ObjFadtSciCmdInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->SciCmdinfo, + sizeof (PlatformRepo->SciCmdinfo), + 1, + CmObject + ); + break; + case EX64ObjFadtPmBlockInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->PmBlockInfo, + sizeof (PlatformRepo->PmBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtGpeBlockInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->GpeBlockInfo, + sizeof (PlatformRepo->GpeBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtXpmBlockInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->XpmBlockInfo, + sizeof (PlatformRepo->XpmBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtXgpeBlockInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->XgpeBlockInfo, + sizeof (PlatformRepo->XgpeBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtSleepBlockInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->SleepBlockInfo, + sizeof (PlatformRepo->SleepBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtResetBlockInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->ResetBlockInfo, + sizeof (PlatformRepo->ResetBlockInfo), + 1, + CmObject + ); + break; + case EX64ObjFadtMiscInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->FadtMiscInfo, + sizeof (PlatformRepo->FadtMiscInfo), + 1, + CmObject + ); + break; + case EX64ObjHpetInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->HpetInfo, + sizeof (PlatformRepo->HpetInfo), + 1, + CmObject + ); + break; + case EX64ObjWsmtFlagsInfo: + Status = SetHandleCmObject ( + CmObjectId, + &PlatformRepo->WsmtFlagsInfo, + sizeof (PlatformRepo->WsmtFlagsInfo), + 1, + CmObject + ); + break; + default: + Status = EFI_NOT_FOUND; + DEBUG (( + DEBUG_ERROR, + "ERROR: Object 0x%x. Status = %r\n", + CmObjectId, + Status + )); + break; + } + + return Status; +} + +/** The GetObject function defines the interface implemented by the + Configuration Manager Protocol for returning the Configuration + Manager Objects. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token An optional token identifying the object. If + unused this must be CM_NULL_TOKEN. + @param [in, out] CmObject Pointer to the Configuration Manager Object + descriptor describing the requested Object. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. +**/ +EFI_STATUS +EFIAPI +AmdPlatformGetObject ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject + ) +{ + EFI_STATUS Status; + + if ((This == NULL) || (CmObject == NULL)) { + ASSERT (This != NULL); + ASSERT (CmObject != NULL); + return EFI_INVALID_PARAMETER; + } + + switch (GET_CM_NAMESPACE_ID (CmObjectId)) { + case EObjNameSpaceStandard: + Status = GetStandardNameSpaceObject (This, CmObjectId, Token, CmObject); + break; + + case EObjNameSpaceArchCommon: + Status = GetArchNameSpaceObject (This, CmObjectId, Token, CmObject); + break; + + case EObjNameSpaceX64: + Status = GetX64NameSpaceObject (This, CmObjectId, Token, CmObject); + break; + + default: + { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: Unknown Namespace Object = 0x%x. Status = %r\n", + CmObjectId, + Status + )); + break; + } + } + + return Status; +} + +/** The SetObject function defines the interface implemented by the + Configuration Manager Protocol for updating the Configuration + Manager Objects. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token An optional token identifying the object. If + unused this must be CM_NULL_TOKEN. + @param [in] CmObject Pointer to the Configuration Manager Object + descriptor describing the Object. + + @retval EFI_UNSUPPORTED This operation is not supported. +**/ +EFI_STATUS +EFIAPI +AmdPlatformSetObject ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN CM_OBJ_DESCRIPTOR *CONST CmObject + ) +{ + EFI_STATUS Status; + + if ((This == NULL) || (CmObject == NULL)) { + ASSERT (This != NULL); + ASSERT (CmObject != NULL); + return EFI_INVALID_PARAMETER; + } + + switch (GET_CM_NAMESPACE_ID (CmObjectId)) { + case EObjNameSpaceArchCommon: + Status = SetArchNameSpaceObject (This, CmObjectId, Token, CmObject); + break; + + case EObjNameSpaceX64: + Status = SetX64NameSpaceObject (This, CmObjectId, Token, CmObject); + break; + + default: + { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: Unknown Namespace Object = 0x%x. Status = %r\n", + CmObjectId, + Status + )); + break; + } + } + + return Status; +}