From dfc242c2dda2010faf99beaf7fd2009bf4287444 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Thu, 5 Sep 2024 10:03:59 +0100 Subject: [PATCH 1/3] MdePkg/Acpi65.h: Add RAS2 table defs and signature as in ACPI 6.5 Add EFI_ACPI_RAS2_PCC_DESCRIPTOR, EFI_ACPI_6_5_RAS2_FEATURE_TABLE and EFI_ACPI_6_5_ACPI_RAS2_FEATURE_TABLE_SIGNATURE. Signed-off-by: Carsten Haitzler --- MdePkg/Include/IndustryStandard/Acpi65.h | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/MdePkg/Include/IndustryStandard/Acpi65.h b/MdePkg/Include/IndustryStandard/Acpi65.h index 42a9aaf860e2c..62d2fac1bfb6b 100644 --- a/MdePkg/Include/IndustryStandard/Acpi65.h +++ b/MdePkg/Include/IndustryStandard/Acpi65.h @@ -1056,6 +1056,26 @@ typedef struct { #define EFI_ACPI_6_5_RASF_PATROL_SCRUB_COMMAND_START_PATROL_SCRUBBER 0x02 #define EFI_ACPI_6_5_RASF_PATROL_SCRUB_COMMAND_STOP_PATROL_SCRUBBER 0x03 +/// +/// ACPI RAS2 PCC Descriptor +/// +typedef struct { + UINT8 PccId; + UINT8 Reserved[2]; + UINT8 RasFeatureType; + UINT32 Instance; +} EFI_ACPI_RAS2_PCC_DESCRIPTOR; + +/// +/// ACPI RAS2 Feature Table definition. +/// +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT16 Reserved; + UINT16 PccCount; + // EFI_ACPI_RAS2_PCC_DESCRIPTOR Descriptors[PccCount]; +} EFI_ACPI_6_5_RAS2_FEATURE_TABLE; + /// /// Memory Power State Table definition. /// @@ -3121,6 +3141,11 @@ typedef struct { /// #define EFI_ACPI_6_5_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE SIGNATURE_32('P', 'S', 'D', 'T') +/// +/// "RAS2" ACPI RAS2 Feature Table +/// +#define EFI_ACPI_6_5_ACPI_RAS2_FEATURE_TABLE_SIGNATURE SIGNATURE_32('R', 'A', 'S', '2') + /// /// "RASF" ACPI RAS Feature Table /// From 1197fb3383ddbe53d764cb9b3583c1738ac62a18 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Thu, 29 Aug 2024 15:06:08 +0100 Subject: [PATCH 2/3] ShellPkg/AcpiView: RAS2 Parser Add a new parser for the RAS2 Table as specified in ACPI6.5 Signed-off-by: Carsten Haitzler --- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 23 ++++ .../Parsers/Ras2/Ras2Parser.c | 118 ++++++++++++++++++ .../UefiShellAcpiViewCommandLib.c | 1 + .../UefiShellAcpiViewCommandLib.inf | 1 + 4 files changed, 143 insertions(+) create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ras2/Ras2Parser.c diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 6427ea7d8a5d4..32816242fc23e 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -1006,6 +1006,29 @@ ParseAcpiPptt ( IN UINT8 AcpiTableRevision ); +/** + This function parses the ACPI RAS2 table. + When trace is enabled this function parses the RAS2 table and + traces the ACPI table fields. + + This function parses the RAS2 ACPI table along with PCC Entries + + This function also performs validation of the ACPI table fields. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiRas2 ( + IN BOOLEAN Trace, + IN UINT8 *Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ); + /** This function parses the ACPI RSDP table. diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ras2/Ras2Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ras2/Ras2Parser.c new file mode 100644 index 0000000000000..9c61b96817ab5 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ras2/Ras2Parser.c @@ -0,0 +1,118 @@ +/** @file + RAS2 table parser + + Copyright (c) 2024, Arm Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.5 Specification - August 2022 +**/ + +#include +#include +#include +#include "AcpiParser.h" +#include "AcpiView.h" + +// Maximum Memory Domain matrix print size. +#define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX 10 + +// Local variables +STATIC CONST UINT16 *Ras2PccDescriptors; + +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; + +/** + An ACPI_PARSER array describing the ACPI RAS2 Table. +*/ +STATIC CONST ACPI_PARSER Ras2Parser[] = { + PARSE_ACPI_HEADER (&AcpiHdrInfo), + { L"Reserved", 2, 36, L"0x%x", NULL, NULL, NULL, NULL }, + { L"PCC Descriptors", 2, 38, L"%d", NULL, (VOID **)&Ras2PccDescriptors, NULL, NULL } +}; + +/** + An ACPI_PARSER array describing the RAS2 PCC ID Entry +*/ +STATIC CONST ACPI_PARSER Ras2StructurePccDescriptor[] = { + { L"PCC ID", 1, 0, L"0x%x", NULL, NULL, NULL, NULL }, + { L"Reserved", 1, 1, L"0x%x", NULL, NULL, NULL, NULL }, + { L"Reserved", 1, 2, L"0x%x", NULL, NULL, NULL, NULL }, + { L"Feature Type", 1, 3, L"0x%x", NULL, NULL, NULL, NULL }, + { L"Instance", 4, 4, L"0x%x", NULL, NULL, NULL, NULL } +}; + +STATIC +VOID +DumpPccEntry ( + IN UINT8 *Ptr, + IN UINT32 Length + ) +{ + ParseAcpi ( + TRUE, + 2, + "PCC Descriptor Entry", + Ptr, + Length, + PARSER_PARAMS (Ras2StructurePccDescriptor) + ); +} + +/** + This function parses the ACPI RAS2 table. + When trace is enabled this function parses the RAS2 table and + traces the ACPI table fields. + + This function parses the following RAS2 structures: + - Pcc Instries + - Entry Pcc ID + - Entry Feature Type + - Entry Pcc Instance + + This function also performs validation of the ACPI table fields. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiRas2 ( + IN BOOLEAN Trace, + IN UINT8 *Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ) +{ + UINT32 Offset; + + if (!Trace) { + return; + } + + // Parse ACPI Header + RAS2 "fixed" fields + Offset = ParseAcpi ( + Trace, + 0, + "RAS2", + Ptr, + AcpiTableLength, + PARSER_PARAMS (Ras2Parser) + ); + + // Table is too small to contain data + if (Offset >= AcpiTableLength) { + return; + } + + // Loop over rest of table for PCC Entries and dump them + while (Offset <= (AcpiTableLength - sizeof (EFI_ACPI_RAS2_PCC_DESCRIPTOR))) { + DumpPccEntry ( + Ptr + Offset, + sizeof (EFI_ACPI_RAS2_PCC_DESCRIPTOR) + ); + Offset += sizeof (EFI_ACPI_RAS2_PCC_DESCRIPTOR); + } // while +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c index 4f4254ac40d54..5e73a39095433 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c @@ -71,6 +71,7 @@ ACPI_TABLE_PARSER ParserList[] = { ParseAcpiPcct }, { EFI_ACPI_6_4_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, ParseAcpiPptt }, + { EFI_ACPI_6_5_ACPI_RAS2_FEATURE_TABLE_SIGNATURE, ParseAcpiRas2 }, { RSDP_TABLE_INFO, ParseAcpiRsdp }, { EFI_ACPI_6_2_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE, ParseAcpiSlit }, { EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, ParseAcpiSpcr }, diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf index 54dddd0ee26d5..7ef8b0afb7b2f 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf @@ -50,6 +50,7 @@ Parsers/Pcct/PcctParser.h Parsers/Pptt/PpttParser.c Parsers/Pptt/PpttParser.h + Parsers/Ras2/Ras2Parser.c Parsers/Rsdp/RsdpParser.c Parsers/Slit/SlitParser.c Parsers/Spcr/SpcrParser.c From fe6b6feca7b6012278a432226a56f0836ad1c457 Mon Sep 17 00:00:00 2001 From: Xianglai Li Date: Wed, 11 Sep 2024 16:58:53 +0800 Subject: [PATCH 3/3] OvmfPkg/LoongArchVirt: Modify loongarch uefi firmware size After the loongarch flash block size is changed from 128K to 256K, qemu requires that the UEFI firmware size be aligned with the flash block size(256K). Otherwise, the firmware cannot be loaded, Use the following code to resolve the old firmware loading problem: mv QEMU_EFI.fd QEMU_EFI.fd-bak cat QEMU_EFI.fd-bak /dev/zero | head -c 16m > ./QEMU_EFI.fd mv QEMU_VARS.fd QEMU_VARS.fd-bak cat QEMU_VARS.fd-bak /dev/zero | head -c 16m > ./QEMU_VARS.fd For the new firmware, we refer to other architecture UEFI and set the UEFI firmware size to align with the flash block size(256K). So for this patch, we set the UEFI firmware size to 256K alignment. Cc: Bibo Mao Cc: Chao Li Signed-off-by: Xianglai Li --- OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc b/OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc index 22373bec6a43c..6d68a9e3a60e4 100644 --- a/OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc +++ b/OvmfPkg/LoongArchVirt/LoongArchVirt.fdf.inc @@ -15,18 +15,8 @@ DEFINE FW_BLOCKS = 0x400 DEFINE FW_SIZE = 0x400000 ############################################################################ -#Flash code layout -#Set Sec size in flash -DEFINE SECFV_SIZE = 0x00010000 - -#Set Pei size in flash -DEFINE PEIFV_SIZE = 0x00040000 - -#Set Dxe size in flash -DEFINE DXEFV_SIZE = 0x00350000 - #Set FVMAIN size -DEFINE FVMAIN_SIZE = $(SECFV_SIZE) + $(PEIFV_SIZE) +$(DXEFV_SIZE) +DEFINE FVMAIN_SIZE = $(FW_SIZE) #Set Memory layout DEFINE SEC_PEI_TEMP_RAM_BASE = 0x10000