IN UINT8 AcpiTableRevision\r
);\r
\r
+/**\r
+ This function parses the ACPI RAS2 table.\r
+ When trace is enabled this function parses the RAS2 table and\r
+ traces the ACPI table fields.\r
+\r
+ This function parses the RAS2 ACPI table along with PCC Entries\r
+\r
+ This function also performs validation of the ACPI table fields.\r
+\r
+ @param [in] Trace If TRUE, trace the ACPI fields.\r
+ @param [in] Ptr Pointer to the start of the buffer.\r
+ @param [in] AcpiTableLength Length of the ACPI table.\r
+ @param [in] AcpiTableRevision Revision of the ACPI table.\r
+**/\r
+VOID\r
+EFIAPI\r
+ParseAcpiRas2 (\r
+ IN BOOLEAN Trace,\r
+ IN UINT8 *Ptr,\r
+ IN UINT32 AcpiTableLength,\r
+ IN UINT8 AcpiTableRevision\r
+ );\r
+\r
/**\r
This function parses the ACPI RSDP table.\r
\r
--- /dev/null
+/** @file\r
+ RAS2 table parser\r
+\r
+ Copyright (c) 2024, Arm Limited. All rights reserved.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+ @par Reference(s):\r
+ - ACPI 6.5 Specification - August 2022\r
+**/\r
+\r
+#include <Library/PrintLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiLib.h>\r
+#include "AcpiParser.h"\r
+#include "AcpiView.h"\r
+\r
+// Maximum Memory Domain matrix print size.\r
+#define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX 10\r
+\r
+// Local variables\r
+STATIC CONST UINT16 *Ras2PccDescriptors;\r
+\r
+STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;\r
+\r
+/**\r
+ An ACPI_PARSER array describing the ACPI RAS2 Table.\r
+*/\r
+STATIC CONST ACPI_PARSER Ras2Parser[] = {\r
+ PARSE_ACPI_HEADER (&AcpiHdrInfo),\r
+ { L"Reserved", 2, 36, L"0x%x", NULL, NULL, NULL, NULL },\r
+ { L"PCC Descriptors", 2, 38, L"%d", NULL, (VOID **)&Ras2PccDescriptors, NULL, NULL }\r
+};\r
+\r
+/**\r
+ An ACPI_PARSER array describing the RAS2 PCC ID Entry\r
+*/\r
+STATIC CONST ACPI_PARSER Ras2StructurePccDescriptor[] = {\r
+ { L"PCC ID", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },\r
+ { L"Reserved", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },\r
+ { L"Reserved", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },\r
+ { L"Feature Type", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },\r
+ { L"Instance", 4, 4, L"0x%x", NULL, NULL, NULL, NULL }\r
+};\r
+\r
+STATIC\r
+VOID\r
+DumpPccEntry (\r
+ IN UINT8 *Ptr,\r
+ IN UINT32 Length\r
+ )\r
+{\r
+ ParseAcpi (\r
+ TRUE,\r
+ 2,\r
+ "PCC Descriptor Entry",\r
+ Ptr,\r
+ Length,\r
+ PARSER_PARAMS (Ras2StructurePccDescriptor)\r
+ );\r
+}\r
+\r
+/**\r
+ This function parses the ACPI RAS2 table.\r
+ When trace is enabled this function parses the RAS2 table and\r
+ traces the ACPI table fields.\r
+\r
+ This function parses the following RAS2 structures:\r
+ - Pcc Instries\r
+ - Entry Pcc ID\r
+ - Entry Feature Type\r
+ - Entry Pcc Instance\r
+\r
+ This function also performs validation of the ACPI table fields.\r
+\r
+ @param [in] Trace If TRUE, trace the ACPI fields.\r
+ @param [in] Ptr Pointer to the start of the buffer.\r
+ @param [in] AcpiTableLength Length of the ACPI table.\r
+ @param [in] AcpiTableRevision Revision of the ACPI table.\r
+**/\r
+VOID\r
+EFIAPI\r
+ParseAcpiRas2 (\r
+ IN BOOLEAN Trace,\r
+ IN UINT8 *Ptr,\r
+ IN UINT32 AcpiTableLength,\r
+ IN UINT8 AcpiTableRevision\r
+ )\r
+{\r
+ UINT32 Offset;\r
+\r
+ if (!Trace) {\r
+ return;\r
+ }\r
+\r
+ // Parse ACPI Header + RAS2 "fixed" fields\r
+ Offset = ParseAcpi (\r
+ Trace,\r
+ 0,\r
+ "RAS2",\r
+ Ptr,\r
+ AcpiTableLength,\r
+ PARSER_PARAMS (Ras2Parser)\r
+ );\r
+\r
+ // Table is too small to contain data\r
+ if (Offset >= AcpiTableLength) {\r
+ return;\r
+ }\r
+\r
+ // Loop over rest of table for PCC Entries and dump them\r
+ while (Offset <= (AcpiTableLength - sizeof (EFI_ACPI_RAS2_PCC_DESCRIPTOR))) {\r
+ DumpPccEntry (\r
+ Ptr + Offset,\r
+ sizeof (EFI_ACPI_RAS2_PCC_DESCRIPTOR)\r
+ );\r
+ Offset += sizeof (EFI_ACPI_RAS2_PCC_DESCRIPTOR);\r
+ } // while\r
+}\r