Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Upstream PlatformPkg for AMD Platform #742

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@
"PcAtChipsetPkg/PcAtChipsetPkg.dec",
"SignedCapsulePkg/SignedCapsulePkg.dec",
"SecurityPkg/SecurityPkg.dec",
"CryptoPkg/CryptoPkg.dec",
"UefiCpuPkg/UefiCpuPkg.dec",
"UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec"
"UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec",
"ShellPkg/ShellPkg.dec"
],
# For host based unit tests
"AcceptableDependencies-HOST_APPLICATION":[
Expand Down Expand Up @@ -125,7 +127,9 @@
"acpimmio",
"glink",
"ehci's",
"uhci's"
"uhci's",
"regac",
"pdecode"
],
"AdditionalIncludePaths": [] # Additional paths to spell check relative to package root (wildcards supported)
},
Expand Down
58 changes: 58 additions & 0 deletions Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,55 @@
# after SMM dispatcher.
SmmCorePlatformHookLib|Include/Library/AmdSmmCorePlatformHookLib.h

## @libraryclass AMD Platform AcDcTimer library
# Provide the function to Set/Clear AcDcTimer
AcDcTimerLib|Include/Library/AcDcTimerLib.h

## @libraryclass AMD Platform CommonSetup library
# Provide the functions to get/set/load common setup options
CommonSetupLib|Include/Library/CommonSetupLib.h

## @libraryclass AMD Platform Password Verification library
# Provide the functions to verify/deploy password for BIOS
AmdBiosPasswordLib|Include/Library/BiosPasswordLib.h

## @libraryclass AMD Platform Flash Update Shell Command library
# Provide the functions to update flash with shell command
FlashShellCommandLib|Include/Library/BiosFlashUpdate.h

## @libraryclass AMD Pci Platform Library
# Provide PciPlatform Library which linked by PciPlatform DXE driver
PciPlatformLib|Include/Library/PciPlatformLib.h

[Guids]
gAmdPlatformPkgTokenSpaceGuid = { 0x663DE733, 0x70E0, 0x4D37, { 0xBB, 0x30, 0x7D, 0x9E, 0xAF, 0x9B, 0xDA, 0xE9 }}

## gAmdPlatformSetupOptions Guid
# This GUID is used to define a namespace for Platform Setup Configuration.
gAmdPlatformSetupOptionsGuid = {0xE863E18A, 0xAC7B, 0x4BFE, {0xAA, 0x49, 0x62, 0xAA, 0x9B, 0x60, 0x48, 0xC6}}

## gAmdPlatformBiosPassword Guid
# This GUID is used to define a namespace for the variable of BiosPassword.
gAmdPlatformBiosPasswordGuid = {0xfbe4a1b1, 0xae60, 0x4f7c, {0xa6, 0x8d, 0x96, 0x2b, 0x1e, 0x3e, 0x6a, 0x63}}

## gAmdTscFrequencyGuid
# This GUID is used for TSC frequency information.
gAmdTscFrequencyGuid = {0x614facf7, 0x1ac6, 0x4b15, {0xa8, 0x8c, 0x2c, 0x1a, 0x70, 0xd7, 0x77, 0xec}}

## gAmdShadowPeimExtractionGuid
# This GUID is used for identify the specific FFS which should be extracted as shadow PEIM.
gAmdShadowPeimExtractionGuid = {0x268e6723, 0xa162, 0x4f4f, {0xa0, 0x4e, 0xde, 0xe5, 0x30, 0xe3, 0xd1, 0xd2}}

[Protocols]
gAmdSpiHcStateProtocolGuid = { 0x189566ab, 0x245, 0x43ae, {0x9d, 0x1, 0xd2, 0x21, 0x1c, 0xb9, 0x1a, 0xda }}
gFakeDeviceIoProtocolGuid = { 0x7fecf70, 0xd7ae, 0x4274, {0x9f, 0x70, 0x78, 0xc8, 0x36, 0x91, 0xd4, 0xfb }}
gEdk2EspiSmmDriverProtocolGuid = { 0x0ecc91df, 0xe165, 0x42ee, {0x82, 0xa7, 0x8d, 0x63, 0x98, 0x53, 0x6a, 0x31 }}
gAmdEspiSmmNorFlashProtocolGuid = { 0x6ef7b652, 0x84b7, 0x4d43, {0x9d, 0x88, 0x04, 0xb3, 0x0c, 0x49, 0xde, 0xd5 }}

## gAmdBeforeConsoleEventProtocol Guid
# This protocol provides the interface which be called before console.
gAmdBeforeConsoleEventProtocolGuid = {0xd11d1d0f, 0x5535, 0x4e35, {0x9b, 0xa7, 0x4a, 0xa8, 0x55, 0x44, 0xef, 0x88}}

[PcdsDynamic]
## Event GUID to trigger logo displaying
# Default set to gMinPlatformPkgTokenSpaceGuid.gBdsEventAfterConsoleReadyBeforeBootOptionGuid
Expand Down Expand Up @@ -121,3 +161,21 @@
gAmdPlatformPkgTokenSpaceGuid.PcdType11OemStrings|NULL|VOID*|0x00030002
gAmdPlatformPkgTokenSpaceGuid.PcdType12SystemCfgOptionsCount|0|UINT8|0x00030003
gAmdPlatformPkgTokenSpaceGuid.PcdType12SystemCfgOptions|NULL|VOID*|0x00030004

[PcdsFeatureFlag]
## Indicates if SecureBoot feature enabled or not.<BR><BR>
# TRUE - The SecureBoot feature enabled as default.<BR>
# FALSE - The SecureBoot feature disabled as default.<BR>
# @Prompt PCIe Bar Resize.
gAmdPlatformPkgTokenSpaceGuid.PcdEnableSecureBootByDefault|FALSE|BOOLEAN|0x2000001C

## Indicates if the PCIe bar can be resizable or not.<BR><BR>
# TRUE - The PCIe bar can be resized.<BR>
# FALSE - The PCIe bar can not be resized.<BR>
# @Prompt PCIe Bar Resize.
gAmdPlatformPkgTokenSpaceGuid.PcdPcieResizableBarSupportDefault|FALSE|BOOLEAN|0x20000024
## Indicates if the system is the first time to boot.<BR><BR>
# TRUE - System is the first time to boot.<BR>
# FALSE - Not the first boot time.<BR>
# @Prompt First Time Boot.
gAmdPlatformPkgTokenSpaceGuid.PcdNetworkBootFirstDefault|FALSE|BOOLEAN|0x2000002C
18 changes: 18 additions & 0 deletions Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf

!if $(TARGET) == RELEASE
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
Expand Down Expand Up @@ -91,6 +92,20 @@
AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.inf
AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.inf
AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.inf
AmdPlatformPkg/Library/DxeCpuDxeDepexLib/DxeCpuDxeDepexLib.inf
AmdPlatformPkg/Library/AcDcTimerLib/AcDcTimerLib.inf
AmdPlatformPkg/Library/PeiCrc32RecoveryLib/PeiCrc32RecoveryLib.inf
AmdPlatformPkg/Library/BiosPasswordLib/BiosPasswordLib.inf
AmdPlatformPkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
AmdPlatformPkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
AmdPlatformPkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
AmdPlatformPkg/Library/CommonSetupLib/CommonSetupPeiLib.inf
AmdPlatformPkg/Library/CommonSetupLib/CommonSetupDxeLib.inf
AmdPlatformPkg/Library/FlashShellCommandLib/FlashShellCommandLib.inf
AmdPlatformPkg/Library/FmpAuthenticationLibPei/FmpAuthenticationLibPei.inf
AmdPlatformPkg/Library/PciPlatformLib/PciPlatformLibNull.inf
AmdPlatformPkg/Library/PeiShadowPeimExtractLib/PeiShadowPeimExtractLib.inf
AmdPlatformPkg/Library/ProcessVideoOpromLib/ProcessVideoOpromLib.inf
AmdPlatformPkg/Universal/HiiConfigRouting/AmdConfigRouting.inf
AmdPlatformPkg/Universal/LogoDxe/JpegLogoDxe.inf # Server platform JPEG logo driver
AmdPlatformPkg/Universal/LogoDxe/LogoDxe.inf # Server platfrom Bitmap logo driver
Expand All @@ -101,3 +116,6 @@
AmdPlatformPkg/Universal/Spi/BoardSpiConfig/BoardSpiConfigSmm.inf
AmdPlatformPkg/Universal/Spi/SpiFvb/SpiFvbDxe.inf
AmdPlatformPkg/Universal/Spi/SpiFvb/SpiFvbSmm.inf

[PcdsDynamicDefault]
gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
76 changes: 76 additions & 0 deletions Platform/AMD/AmdPlatformPkg/Include/Library/AcDcTimerLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/** @file
The header file for AcDcTimerLib library.

Copyright (C) 2019 - 2024, Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef AC_DC_TIMER_LIB_H_
#define AC_DC_TIMER_LIB_H_

#define ACPI_MMIO_BASE 0xFED80000ul

#define IOMUX_BASE 0xD00
#define FCH_GPIO_REG23 0x17

#define FCH_GPIOX05C_AGPIO23_SGPIO_LOAD_MDIO1_SDA 0xFED8155Cul
#define BYTE_0 0x00
#define BYTE_1 0x01
#define BYTE_2 0x02
#define BYTE_3 0x03

#define ACDC_BASE 0x1D00
#define FCH_ACDC_REG00 0x00
#define FCH_ACDC_REG08 0x08
#define FCH_ACDC_REG10 0x10
#define FCH_ACDC_REG18 0x18
#define FCH_ACDC_REG21 0x21

#define AC_PRESENT 0x00
#define AC_TIMER_EN BIT0
#define DC_TIMER_EN BIT1

#define SLP_TYPE_SUPPORT_S0I3 BIT0
#define SLP_TYPE_SUPPORT_S3 BIT1
#define SLP_TYPE_SUPPORT_S4S5 BIT2

/**
Set AcDcTimer.

@param[in] AcDcTimerSelect Select AC or DC Timer.
Bit0 = 1 = Enable AC Timer.
Bit1 = 1 = Enable DC Timer.
@param[in] WakeupSupport Select ACDC Timer wake up support.
Bit0 = 1 = Enable wake in S0I3 state.
Bit1 = 1 = Enable wake in S3 state (SLP_TYP = 3, and !G0_State).
Bit2 = 1 = Enable wake in S4/S5 state (SLP_TYP = 4 or 5, and !G0_State).
@param[in] AcTimer The number of seconds for AC Timer.
@param[in] DcTimer The number of seconds for DC Timer.

**/
VOID
EFIAPI
SetAcDcTimer (
IN UINT8 AcDcTimerSelect,
IN UINT8 WakeupSupport,
IN UINT32 AcTimer,
IN UINT32 DcTimer
);

/**
Clear AcDcTimer.

@param[in] AcDcTimerSelect Select AC or DC Timer.
Bit0 = 1 = Clear AC Timer.
Bit1 = 1 = Clear DC Timer.

**/
VOID
EFIAPI
ClearAcDcTimer (
IN UINT8 AcDcTimerSelect
);

#endif // AC_DC_TIMER_LIB_H_
52 changes: 52 additions & 0 deletions Platform/AMD/AmdPlatformPkg/Include/Library/BiosFlashUpdate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/** @file
The header file for AMD BIOS Flash DXE Driver.
And also for AMD BIOS Flash Shell Command.

Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef BIOS_FLASH_UPDATE_H_
#define BIOS_FLASH_UPDATE_H_

#include <Uefi.h>

#define EFI_AMD_FLASH_VARIABLE_NAME L"AMDFLASH"
#define EFI_AMD_FLASH_EX_VARIABLE_NAME L"AMDFLASH_EX"
#define EFI_AMD_FLASH_BIOS_FILE_NAME L"\\EFI\\AMDFLASH\\BIOS.FD"
#define IOHC_NB_SMN_INDEX_2_BIOS 0x00B8
#define IOHC_NB_SMN_DATA_2_BIOS 0x00BC
#define FCH_SPI_SMN_BASE 0x2DC4000
#define FCH_SPI_MMIO_REG60 0x60
#define AMD_BIOS_FLASH_OPTION_NV_STORAGE 0x0001
#define PRESERVED_REGION_INFO_COUNT 2

typedef union {
struct {
UINT16 OptionNumber;
UINT16 Flags;
} Option;
UINT32 FlashOption;
} AMD_BIOS_FLASH_OPTION;

typedef struct {
UINT64 Offset;
UINT64 Size;
} PRESERVED_REGION_INFO_ENTRY;

/**
To perform flash update according specific boot option.

@retval EFI_SUCCESS BIOS flash update success.
@retval Others To reference other functions.

**/
EFI_STATUS
EFIAPI
AmdBiosFlashCallBack (
VOID
);

#endif // BIOS_FLASH_UPDATE_H_
59 changes: 59 additions & 0 deletions Platform/AMD/AmdPlatformPkg/Include/Library/BiosPasswordLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/** @file
The header file for Bios password verification library.

Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef BIOS_PASSWORD_LIB_H_
#define BIOS_PASSWORD_LIB_H_

#define PASSWORD_SALT_SIZE 32

#define MAX_BIOS_PASSWORD_RETRY_COUNT 5

#define BIOS_PASSWORD_MAX_LENGTH 32

#define BIOS_PASSWORD_POPUP_STRING_MAX_LENGTH 100

#define BIOS_PASSWORD_VARIABLE_NAME L"AmdBiosPassword"

#pragma pack(1)
typedef struct {
UINT8 PasswordHash[SHA256_DIGEST_SIZE];
UINT8 PasswordSalt[PASSWORD_SALT_SIZE];
} BIOS_PASSWORD_VARIABLE;
#pragma pack()

VOID
EFIAPI
ProcessBiosPasswordVerification (
VOID
);

BOOLEAN
EFIAPI
PasswordIsFullZero (
IN CHAR8 *Password
);

BOOLEAN
EFIAPI
GenerateCredential (
IN UINT8 *Buffer,
IN UINTN BufferSize,
IN UINT8 *SaltValue,
OUT UINT8 *Credential
);

EFI_STATUS
EFIAPI
PopupPasswordInputWindows (
IN CHAR16 *PopUpString1,
IN CHAR16 *PopUpString2,
IN OUT CHAR8 *Password
);

#endif // BIOS_PASSWORD_LIB_H_
68 changes: 68 additions & 0 deletions Platform/AMD/AmdPlatformPkg/Include/Library/CommonSetupLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/** @file
The header file for the setup common lib.

Copyright (C) 2019 - 2024, Advanced Micro Devices, Inc. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef COMMON_SETUP_LIB_H_
#define COMMON_SETUP_LIB_H_

#include <Uefi.h>
#include <Universal/CommonSetupDxe/CommonSetupOptions.h>

/**
Retrieve common setup configuration data.

@param[out] CommonSetupOptions Pointer to the structure of COMMON_SETUP_OPTIONS,
this pointer must be allocated with sizeof(COMMON_SETUP_OPTIONS)
before being called.

@retval EFI_SUCCESS The common setup options are successfully retrieved.
@retval EFI_INVALID_PARAMETER NULL pointer.
@return others Failed to retrieve common setup options.

**/
EFI_STATUS
EFIAPI
GetCommonSetupOptions (
OUT COMMON_SETUP_OPTIONS *CommonSetupOptions
);

/**
Set common setup configuration data in Variable, **ONLY** available in DXE.

@param[in] CommonSetupOptions Pointer to the structure of COMMON_SETUP_OPTIONS,
this pointer must be allocated with sizeof(COMMON_SETUP_OPTIONS)
before being called.

@retval EFI_SUCCESS The common setup options are successfully saved to Variable.
@retval EFI_INVALID_PARAMETER NULL pointer.
@retval others Failed to save the struct to Variable.

**/
EFI_STATUS
EFIAPI
SetCommonSetupOptions (
IN COMMON_SETUP_OPTIONS *CommonSetupOptions
);

/**
Load default value for common setup configuration.

@param[out] CommonSetupOptions Pointer to the structure of COMMON_SETUP_OPTIONS,
this pointer must be allocated with sizeof(COMMON_SETUP_OPTIONS)
before being called.

@retval EFI_SUCCESS The common setup options are successfully loaded to default value.

**/
EFI_STATUS
EFIAPI
LoadCommonSetupDefault (
OUT COMMON_SETUP_OPTIONS *CommonSetupOptions
);

#endif // COMMON_SETUP_LIB_H_
Loading