From a70c8729668f30de067f4b9db2e69baba283856e Mon Sep 17 00:00:00 2001 From: Sami Mujawar Date: Wed, 14 May 2025 13:26:03 +0100 Subject: ShellPkg/AcpiView: Add parser for CCEL ACPI table The ACPI 6.5 specification introduces the CCEL (CC Event Log) table in section 5.2.34: https://uefi.org/specs/ACPI/6.5/ 05_ACPI_Software_Programming_Model.html#cc-event-log-acpi-table Extend AcpiView with a parser to decode and display CCEL table contents. This allows users to inspect CCEL tables from the UEFI Shell. Signed-off-by: Sami Mujawar --- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 19 +++ .../Parsers/Ccel/CcelParser.c | 127 +++++++++++++++++++++ .../UefiShellAcpiViewCommandLib.c | 1 + .../UefiShellAcpiViewCommandLib.inf | 1 + 4 files changed, 148 insertions(+) create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ccel/CcelParser.c diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 9d559b39ea..34bfceb78e 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -698,6 +698,25 @@ ParseAcpiBgrt ( IN UINT8 AcpiTableRevision ); +/** + This function parses the ACPI CCEL table. + When trace is enabled this function parses the CCEL table and + traces 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 +ParseAcpiCcel ( + IN BOOLEAN Trace, + IN UINT8 *Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ); + /** This function parses the ACPI DBG2 table. When trace is enabled this function parses the DBG2 table and diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ccel/CcelParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ccel/CcelParser.c new file mode 100644 index 0000000000..5044182fa7 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ccel/CcelParser.c @@ -0,0 +1,127 @@ +/** @file + CCEL table parser + + Copyright (c) 2025, Arm Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.5 Specification - 29 Aug 2022 +**/ + +#include +#include +#include "AcpiParser.h" +#include "AcpiTableParser.h" +#include "AcpiViewConfig.h" + +// Local variables. +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; + +/** + Print the CC Type. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. +**/ +VOID +EFIAPI +PrintCcType ( + IN CONST CHAR16 *Format OPTIONAL, + IN UINT8 *Ptr, + IN UINT32 Length + ) +{ + UINT8 CcType; + + CcType = *Ptr; + switch (CcType) { + case EFI_ACPI_6_5_CC_TYPE_NONE: + Print (L"CC Type '%u' - None", CcType); + break; + case EFI_ACPI_6_5_CC_TYPE_SEV: + Print (L"CC Type '%u' - SEV", CcType); + break; + case EFI_ACPI_6_5_CC_TYPE_TDX: + Print (L"CC Type '%u' - TDX", CcType); + break; + case EFI_ACPI_6_5_CC_TYPE_APTEE: + Print (L"CC Type '%u' - APTEE", CcType); + break; + case EFI_ACPI_6_5_CC_TYPE_ARMCCA: + Print (L"CC Type '%u' - Arm CCA", CcType); + break; + default: + Print (L"CC Type '%u' - Unknown", CcType); + } // switch +} + +/** + This function validates CC Type field. + + @param [in] Ptr Pointer to the start of the field data. + @param [in] Length Length of the field. + @param [in] Context Pointer to context specific information. +**/ +VOID +EFIAPI +ValidateCcType ( + IN UINT8 *Ptr, + IN UINT32 Length, + IN VOID *Context + ) +{ + UINT8 CcType; + + CcType = *Ptr; + + if (CcType > EFI_ACPI_6_5_CC_TYPE_ARMCCA) { + IncrementErrorCount (); + Print (L"\nERROR : Invalid/Unknown CC Type - %u.\n", CcType); + } +} + +/** + An ACPI_PARSER array describing the ACPI CCEL Table. +**/ +STATIC CONST ACPI_PARSER CcelParser[] = { + PARSE_ACPI_HEADER (&AcpiHdrInfo), + { L"CC Type", 1, 36, L"%d", NULL, NULL, NULL, NULL }, + { L"CC Subtype", 1, 37, L"%d", PrintCcType, NULL, ValidateCcType, NULL }, + { L"Reserved", 2, 38, NULL, DumpReserved, NULL, ValidateReserved, NULL }, + { L"Log Area Minimum Length (LAML)",8, 40, L"0x%lx", NULL, NULL, NULL, NULL }, + { L"Log Area Start Address (LASA)",8, 48, L"0x%lx", NULL, NULL, NULL, NULL } +}; + +/** + This function parses the ACPI CCEL table. + When trace is enabled this function parses the CCEL table and + traces 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 +ParseAcpiCcel ( + IN BOOLEAN Trace, + IN UINT8 *Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ) +{ + if (!Trace) { + return; + } + + ParseAcpi ( + TRUE, + 0, + "CCEL", + Ptr, + AcpiTableLength, + PARSER_PARAMS (CcelParser) + ); +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c index 12e3940a05..e64888dd30 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c @@ -55,6 +55,7 @@ ACPI_TABLE_PARSER ParserList[] = { { EFI_ACPI_ARM_AGDI_TABLE_SIGNATURE, ParseAcpiAgdi }, { EFI_ACPI_6_4_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_SIGNATURE, ParseAcpiApmt }, { EFI_ACPI_6_2_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE, ParseAcpiBgrt }, + { EFI_ACPI_6_5_CONFIDENTIAL_COMPUTING_EVENT_LOG_TABLE_SIGNATURE, ParseAcpiCcel }, { EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, ParseAcpiDbg2 }, { EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiDsdt }, diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf index 1a42b73169..8f223a8a4f 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf @@ -33,6 +33,7 @@ Parsers/Agdi/AgdiParser.c Parsers/Apmt/ApmtParser.c Parsers/Bgrt/BgrtParser.c + Parsers/Ccel/CcelParser.c Parsers/Dbg2/Dbg2Parser.c Parsers/Dsdt/DsdtParser.c Parsers/Einj/EinjParser.c -- cgit v1.2.3