Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ampere Altra Mt. Jade: Upstream bugfixes, improvements, and features #193

Merged
35 commits merged into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b893204
AmpereAltraPkg: Update platform HOB to align with SRP 2.10
nhivp Sep 6, 2024
7dfbf24
AmpereAltraPkg: Update NVPARAM definitions to align with SRP 2.10
nhivp Sep 6, 2024
a876879
AmpereAltraPkg/RasConfigDxe: Correct the default value of HW EINJ
nhivp Aug 29, 2024
82dd002
AmpereAltraPkg/RasConfigDxe: Add DDR CE Window control
nhivp Aug 29, 2024
5af8fce
AmpereAltraPkg/MemInfoDxe: Add auto mode to ECC mode option
nhivp Sep 4, 2024
d1d86ed
AmpereAltraPkg, JadePkg: RTC: Update RTC datetime to SMpro
nhivp Jan 5, 2022
209fd9d
AmpereAltraPk/BootProgress: Support to report OS booting stage
nhivp Mar 2, 2022
0d7a468
JadePkg/AcpiTables: DSDT: Add LED device
nhivp Sep 6, 2024
6c282d9
AmpereAltraPkg/ArmPlatformLib: Initialize UART2 for WinDbg
nhivp Sep 6, 2024
dd6fdf8
AmpereAltraPkg/Platform/Ac01.h: Add Ampere MPIDR definitions
nhivp Sep 6, 2024
577b530
AmpereAltraPkg/ArmPlatformLib: Update MPIDR value
nhivp Sep 6, 2024
348a6ac
JadePkg/AcpiPlatformDxe: Update to reflect the new MPIDR format
nhivp Sep 6, 2024
9a164c8
JadePkg/AcpiPlatformDxe: Advertise ATS support
nhivp Sep 7, 2024
04ed84b
JadePkg/AcpiPlatformDxe: Correct DSU patching
nhivp Sep 7, 2024
415447c
JadePkg/AcpiPlatformDxe: Fix kernel crash when forcing 1P boot
nhivp Feb 17, 2022
4cd8e83
JadePkg/AcpiPlatformDxe: Skip PCIe MMIO32 resource patching for RCA0/1
nhivp Aug 30, 2022
fccd953
JadePkg/AcpiPlatformDxe: BERT: Fix memory vulnerability
nhivp Aug 22, 2021
64bb339
JadePkg/AcpiPlatformDxe: APEI: Add support for BERT Record Retention
nhivp Oct 22, 2021
f6b9978
JadePkg/AcpiPlatformDxe: Add ACPI BDAT table
nhivp Sep 7, 2024
d7ae4fe
AmpereAltraPkg/CpuConfigDxe: Add SLC as L3 Cache configuration
nhivp Sep 6, 2024
919f4b6
AmpereAltraPkg/PlatformInfoDxe: Add SLC/L3 cache information
nhivp Sep 6, 2024
1612a6d
JadePkg/AcpiPlatformDxe: Update ACPI PPTT table
nhivp Sep 6, 2024
bb95d65
JadePkg/AcpiPlatformDxe: Add SLC node to ACPI PPTT table
nhivp Sep 6, 2024
ae25730
JadePkg/SmbiosPlatformDxe: Add System Level Cache (SLC)
nhivp Sep 7, 2024
2ef7e96
JadePkg/OemMiscLib: Update SMBIOS Type 1,2,3 with FRU info
nhivp Sep 8, 2024
9db4f3a
AmpereAltraPkg/AmpereCpuLib: Add SKU and serial number functions
nhivp Sep 8, 2024
19e87a3
JadePkg/OemMiscLib: Populate processor serial and part number
nhivp Sep 8, 2024
6b2015e
JadePkg/OemMiscLib: Correct CPU speed
nhivp Sep 8, 2024
68f766b
AmpereAltraPkg: Add PlatformInitDxe module
nhivp Sep 8, 2024
1b1ce1b
JadePkg: Remove SmbiosMemInfoDxe
nhivp Sep 8, 2024
91a0ffc
AmpereAltraPkg/Ac01.h: Add I2C address in slave socket
nhivp Sep 8, 2024
a482886
JadePkg: Add IOExpanderLib
nhivp Sep 8, 2024
901fca9
JadePkg/SmbiosPlatformDxe: Update slot information in type 9
nhivp Sep 8, 2024
23561bf
JadePkg: Consolidate SMBIOS PCDs
nhivp Sep 8, 2024
4e79d5c
JadePkg/OemMiscLib: Rectify the cache info
nhivp Sep 8, 2024
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
18 changes: 17 additions & 1 deletion Platform/Ampere/JadePkg/AcpiTables/Dsdt.asl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file

Copyright (c) 2020 - 2023, Ampere Computing LLC. All rights reserved.<BR>
Copyright (c) 2020 - 2024, Ampere Computing LLC. All rights reserved.<BR>

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

Expand Down Expand Up @@ -1020,6 +1020,22 @@ DefinitionBlock("Dsdt.aml", "DSDT", 0x02, "Ampere", "Jade", 1) {
}
}

//
// LED Device
//
Device (LED) {
Name (_HID, "AMPC0008")
Name (_CCA, ONE)
Name (_STR, Unicode ("Altra LED Device"))

Name (_DSD, Package () {
ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package () { "uuid", Package (4) { 0x5598273c, 0xa49611ea, 0xbb370242, 0xac130002 }},
}
})
}

Include ("PCI-S0.Rca01.asi")
Include ("PCI-S0.asi")
Include ("PCI-S1.asi")
Expand Down
187 changes: 100 additions & 87 deletions Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file

Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
Copyright (c) 2020 - 2024, Ampere Computing LLC. All rights reserved.<BR>

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

Expand All @@ -17,6 +17,70 @@
UINT8 AMPERE_GUID[16] = {0x8d, 0x89, 0xed, 0xe8, 0x16, 0xdf, 0xcc, 0x43, 0x8e, 0xcc, 0x54, 0xf0, 0x60, 0xef, 0x15, 0x7f};
CHAR8 DEFAULT_BERT_REBOOT_MSG[BERT_MSG_SIZE] = "Unknown reboot reason";

BOOLEAN
IsBertStatusValid (
BERT_ERROR_STATUS *BertStatus
)
{
if (CompareMem (BertStatus->Guid, AMPERE_GUID, sizeof (AMPERE_GUID)) == 0) {
if (BertStatus->BertRev == CURRENT_BERT_VERSION) {
return TRUE;
}
}

return FALSE;
}

/*
Create a default BertErrorStatus In SPINOR
*/
VOID
CreateDefaultBertStatus (
VOID
)
{
UINTN Length = sizeof (BERT_ERROR_STATUS);
BERT_ERROR_STATUS BertStatus = { 0 };

CopyMem (BertStatus.Guid, AMPERE_GUID, sizeof (AMPERE_GUID));
BertStatus.BertRev = CURRENT_BERT_VERSION;
BertStatus.DefaultBert = 1;
BertStatus.Overflow = 0;
BertStatus.PendingUefi = 0;
BertStatus.PendingBmc = 0;

FlashEraseCommand (BERT_SPI_ADDRESS_STATUS, Length);
FlashWriteCommand (
BERT_SPI_ADDRESS_STATUS,
&BertStatus,
Length
);
}

/*
Update BertErrorStatus In SPINOR
*/
VOID
UpdateBertStatus (
BERT_ERROR_STATUS *BertStatus
)
{
UINTN Length = sizeof (BERT_ERROR_STATUS);

BertStatus->DefaultBert = 1;
BertStatus->PendingUefi = 0;
if (BertStatus->PendingBmc == 0) {
BertStatus->Overflow = 0;
}

FlashEraseCommand (BERT_SPI_ADDRESS_STATUS, Length);
FlashWriteCommand (
BERT_SPI_ADDRESS_STATUS,
BertStatus,
Length
);
}

STATIC VOID
AcpiApeiUninstallTable (
UINT32 Signature
Expand Down Expand Up @@ -118,17 +182,16 @@ AdjustBERTRegionLen (
* Retrieve Bert data from SPI NOR
*/
VOID
EFIAPI
PullBertSpinorData (
APEI_CRASH_DUMP_DATA *BertErrorData
UINT8 *BertData,
UINT64 BertSpiAddress,
UINTN Length
)
{
UINTN Length;

Length = sizeof (*BertErrorData);

FlashReadCommand (
BERT_FLASH_OFFSET,
BertErrorData,
BertSpiAddress,
BertData,
Length
);
}
Expand Down Expand Up @@ -198,81 +261,18 @@ WrapBertErrorData (
*/
VOID
CreateDefaultBertData (
APEI_BERT_ERROR_DATA *Data
APEI_CRASH_DUMP_DATA *Data
)
{
Data->Type = RAS_TYPE_BERT_PAYLOAD3;
Data->Vendor.Type = RAS_TYPE_BERT_PAYLOAD3;
Data->BertRev = CURRENT_BERT_VERSION;
AsciiStrCpyS (
Data->Msg,
Data->Vendor.Msg,
BERT_MSG_SIZE,
DEFAULT_BERT_REBOOT_MSG
);
}

/*
* Ensures BertErrorData In SPINOR matches
* the record produced by CreateDefaultBertData.
* @param Bed Crash dump Data
*/
VOID
WriteSpinorDefaultBertTable (
APEI_CRASH_DUMP_DATA *Bed
)
{
UINT8 BertRev;
UINTN Length;
UINT64 Offset;
UINT32 MsgDiff;
APEI_BERT_ERROR_DATA DefaultData = {0};

CreateDefaultBertData (&DefaultData);
if ((Bed->Vendor.Type != DefaultData.Type)) {
Offset = BERT_FLASH_OFFSET +
OFFSET_OF (APEI_CRASH_DUMP_DATA, Vendor) +
OFFSET_OF (APEI_BERT_ERROR_DATA, Type);
Length = sizeof (DefaultData.Type);
FlashEraseCommand (Offset, Length);
FlashWriteCommand (Offset, &(DefaultData.Type), Length);
}

if ((Bed->Vendor.SubType != DefaultData.SubType)) {
Offset = BERT_FLASH_OFFSET +
OFFSET_OF (APEI_CRASH_DUMP_DATA, Vendor) +
OFFSET_OF (APEI_BERT_ERROR_DATA, SubType);
Length = sizeof (DefaultData.SubType);
FlashEraseCommand (Offset, Length);
FlashWriteCommand (Offset, &(DefaultData.SubType), Length);
}

if ((Bed->Vendor.Instance != DefaultData.Instance)) {
Offset = BERT_FLASH_OFFSET +
OFFSET_OF (APEI_CRASH_DUMP_DATA, Vendor) +
OFFSET_OF (APEI_BERT_ERROR_DATA, Instance);
Length = sizeof (DefaultData.Instance);
FlashEraseCommand (Offset, Length);
FlashWriteCommand (Offset, &(DefaultData.Instance), Length);
}

MsgDiff = AsciiStrnCmp (Bed->Vendor.Msg, DefaultData.Msg, BERT_MSG_SIZE);
if (MsgDiff != 0) {
Offset = BERT_FLASH_OFFSET +
OFFSET_OF (APEI_CRASH_DUMP_DATA, Vendor) +
OFFSET_OF (APEI_BERT_ERROR_DATA, Msg);
Length = sizeof (DefaultData.Msg);
FlashEraseCommand (Offset, Length);
FlashWriteCommand (Offset, &(DefaultData.Msg), Length);
}

if (Bed->BertRev != CURRENT_BERT_VERSION) {
Offset = BERT_FLASH_OFFSET + OFFSET_OF (APEI_CRASH_DUMP_DATA, BertRev);
Length = sizeof (Bed->BertRev);
BertRev = CURRENT_BERT_VERSION;
FlashEraseCommand (Offset, Length);
FlashWriteCommand (Offset, &BertRev, Length);
}

}

/*
* Checks Status of NV_SI_RAS_BERT_ENABLED
* Returns TRUE if enabled and FALSE if disabled
Expand Down Expand Up @@ -308,10 +308,6 @@ WriteDDRBertTable (
{
VOID *Blk = (VOID *)BERT_DDR_OFFSET;

/*
* writing sizeof data to ddr produces alignment error
* this is a temporary workaround
*/
CopyMem (Blk, Data, BERT_DDR_LENGTH);
}

Expand All @@ -324,24 +320,41 @@ AcpiPopulateBert (
)
{
APEI_CRASH_DUMP_BERT_ERROR *DDRError;
BERT_ERROR_STATUS BertStatus;

DDRError =
(APEI_CRASH_DUMP_BERT_ERROR *)
AllocateZeroPool (sizeof (APEI_CRASH_DUMP_BERT_ERROR));
DDRError = (APEI_CRASH_DUMP_BERT_ERROR *)AllocateZeroPool (BERT_DDR_LENGTH);

if (DDRError == NULL) {
return EFI_OUT_OF_RESOURCES;
}

if (IsBertEnabled ()) {
PullBertSpinorData (&(DDRError->Bed));
if ((DDRError->Bed.BertRev == CURRENT_BERT_VERSION)) {
WrapBertErrorData (DDRError);
WriteDDRBertTable (DDRError);
PullBertSpinorData ((UINT8 *)&BertStatus, BERT_SPI_ADDRESS_STATUS, sizeof (BERT_ERROR_STATUS));
if (IsBertStatusValid (&BertStatus)) {
if (BertStatus.PendingUefi == 1) {
PullBertSpinorData ((UINT8 *)&(DDRError->Bed), BERT_FLASH_OFFSET, sizeof (APEI_CRASH_DUMP_DATA));
if (DDRError->Bed.BertRev == BertStatus.BertRev) {
WrapBertErrorData (DDRError);
WriteDDRBertTable (DDRError);
} else {
// If we are here something is out of sync. Reinit BERT section
FlashEraseCommand (BERT_FLASH_OFFSET, 0x1000);
CreateDefaultBertStatus ();
goto AcpiPopulateBertEnd;
}
} else if (BertStatus.DefaultBert == 1) {
CreateDefaultBertData (&(DDRError->Bed));
WrapBertErrorData (DDRError);
WriteDDRBertTable (DDRError);
}
UpdateBertStatus (&BertStatus);
} else {
FlashEraseCommand (BERT_FLASH_OFFSET, 0x1000);
CreateDefaultBertStatus ();
}
WriteSpinorDefaultBertTable (&(DDRError->Bed));
}

AcpiPopulateBertEnd:
FreePool (DDRError);
return EFI_SUCCESS;
}
Expand Down
65 changes: 61 additions & 4 deletions Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiApei.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file

Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>
Copyright (c) 2020 - 2024, Ampere Computing LLC. All rights reserved.<BR>

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

Expand Down Expand Up @@ -46,7 +46,7 @@
#define RASIP_CRASH_SIZE 0x1000
#define HEST_NUM_ENTRIES_PER_SOC 3

#define CURRENT_BERT_VERSION 0x11
#define CURRENT_BERT_VERSION 0x12
#define BERT_FLASH_OFFSET 0x91B30000ULL
#define BERT_DDR_OFFSET 0x88230000ULL
#define BERT_DDR_LENGTH 0x50000
Expand Down Expand Up @@ -75,12 +75,67 @@ typedef struct {
EFI_ACPI_6_3_GENERIC_ERROR_DATA_ENTRY_STRUCTURE Ged;
APEI_CRASH_DUMP_DATA Bed;
} APEI_CRASH_DUMP_BERT_ERROR;

/*
* The BERT regions is 0x50000 in size. The SPI-NOR sector size is 0x1000 (4KB).
* So there is 80 sectors available for BERT errors.
*
* BERT error record must be persistent across boots on catastrophic errors
* until the BMC and UEFI have had a chance to retrieve the information. To
* support this, the BERT is sectioned off into two different sections.
*
* -----------------------------------
* | BERT Error Record | sectors 0-61 (4KB * 62 = 248KB)
* | |
* -----------------------------------
* | Unused/Reserved | sectors 62-78 (4KB * 17 = 68KB)
* | |
* -----------------------------------
* | BERT Error Record Status | sector 79 (4KB x 1 = 4KB)
* | | offset 79 * 0x1000 = 0x4F000
* -----------------------------------
*
* BERT Error Record:
* - Catastrophic Full BERT Error Record (persistent until read by BMC and UEFI)
* BERT Error Record Status:
* - DefaultBert: Indicate Default Bert Present
* - Set by UEFI on boot and cleared by SCP on shutdown, reboot, or crash
* - 0 = Default BERT not valid
* - 1 = Default BERT valid
* - Overflow: Indicate Full Crash Capture overflow before
* - Set by SCP if PendingUefi or PendingBMC was set and to be cleared by UEFI
* if PendingUefi and PendingBMC are cleared.
* - 0 = No overflow
* - 1 = Record has overflowed
* - PendingUefi: Indicate Pending UEFI detection
* - Set by SCP and to be cleared by UEFI
* - 0 = Pending UEFI detection not valid
* - 1 = Pending UEFI detection valid
* - PendingBmc: Indicate Pending BMC detection
* - Set by SCP and to be cleared by BMC
* - 0 = Pending BMC detection not valid
* - 1 = Pending BMC detection valid
*/

typedef struct {
UINT8 Guid[16]; /* [0x00] set to AMPERE_GUID */
UINT8 BertRev; /* [0x10] set to BERT revision */
UINT8 Reserved0[7]; /* [----] Reserved */
UINT8 DefaultBert; /* [0x18] Indicate Default Bert Present */
UINT8 Overflow; /* [----] Indicate Full Crash Capture overflow detected */
UINT8 PendingUefi; /* [----] Indicate Pending UEFI detection */
UINT8 PendingBmc; /* [----] Indicate Pending BMC detection */
UINT8 Reserved1[4]; /* [----] Reserved */
} BERT_ERROR_STATUS;

#define BERT_SPI_ADDRESS_STATUS (BERT_FLASH_OFFSET + 0x4F000)

#pragma pack()

VOID
EFIAPI
CreateDefaultBertData (
APEI_BERT_ERROR_DATA *Data
APEI_CRASH_DUMP_DATA *Data
);

VOID
Expand All @@ -92,7 +147,9 @@ WrapBertErrorData (
VOID
EFIAPI
PullBertSpinorData (
APEI_CRASH_DUMP_DATA *BertErrorData
UINT8 *BertData,
UINT64 BertSpiAddress,
UINTN Length
);

VOID
Expand Down
Loading
Loading