Skip to content

Commit

Permalink
AmdPlatformPkg: Add Configuration manager driver
Browse files Browse the repository at this point in the history
Adds configuration manager driver for AMD platform.
This driver provides configuration information to the
ACPI or SMBIOS generator libraries.
  • Loading branch information
Abdul Lateef Attar authored and Abdul Lateef Attar committed Nov 12, 2024
1 parent 2d66a9e commit f6d56a3
Show file tree
Hide file tree
Showing 4 changed files with 1,120 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
#include <IndustryStandard/HighPrecisionEventTimerTable.h>
#include <IndustryStandard/WindowsSmmSecurityMitigationTable.h>
#include <IndustryStandard/ServiceProcessorManagementInterfaceTable.h>
#include <Library/BaseMemoryLib.h>
#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;
}
Original file line number Diff line number Diff line change
@@ -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 <StandardNameSpaceObjects.h>
#include <X64NameSpaceObjects.h>
#include <ArchCommonNameSpaceObjects.h>

/** 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_
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit f6d56a3

Please sign in to comment.