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

ShellPkg: Add support to parse SPMI table in acpiview #5980

Open
wants to merge 2 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
23 changes: 22 additions & 1 deletion ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
Copyright (c) 2016 - 2024, Arm Limited. All rights reserved.
Copyright (c) 2022, AMD Incorporated. All rights reserved.
Copyright (C) 2022 - 2024, Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

Expand Down Expand Up @@ -1097,6 +1097,27 @@ ParseAcpiSpcr (
IN UINT8 AcpiTableRevision
);

/**
This function parses the ACPI SPMI table.
When trace is enabled this function parses the SPMI table and
traces the ACPI table fields.

This function also performs validations 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
ParseAcpiSpmi (
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
);

/**
This function parses the ACPI SRAT table.
When trace is enabled this function parses the SRAT table and
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/** @file
SPMI table parser

Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
- IPMI 2.0 Specification - October 2013
**/

#include <IndustryStandard/Acpi.h>
#include <Library/UefiLib.h>
#include "AcpiParser.h"
#include "AcpiTableParser.h"

// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO mAcpiHdrInfo;

/**
Validate Interface Type.

@param [in] Ptr Pointer to the start of the field data.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateInterfaceType (
IN UINT8 *Ptr,
IN VOID *Context
)
{
if (*Ptr > 5) {
IncrementErrorCount ();
Print (L"\nError: Invalid IPMI Interface type %d", *Ptr);
}
}

/// An ACPI_PARSER array describing the ACPI SPMI table.
STATIC CONST ACPI_PARSER SpmiParser[] = {
PARSE_ACPI_HEADER (&mAcpiHdrInfo),
{ L"Interface Type", 1, 36, L"%d", NULL, NULL, ValidateInterfaceType, NULL },
{ L"Reserved", 1, 37, L"%x", NULL, NULL, NULL, NULL },
{ L"Specification Revision", 2, 38, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Interrupt Type", 1, 40, L"%d", NULL, NULL, NULL, NULL },
{ L"GPE", 1, 41, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 1, 42, L"%x", NULL, NULL, NULL, NULL },
{ L"PCI Device Flag", 1, 43, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Global System Interrupt", 4, 44, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Base Address", 12, 48, NULL, DumpGas, NULL, NULL, NULL },
{ L"PCI Segment Group No. / UID Byte 1",1, 60, L"0x%x", NULL, NULL, NULL, NULL },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This format looks weird to me, was this done by the Uncrustify?

{ L"PCI Bus No. / UID Byte 2", 1, 61, L"0x%x", NULL, NULL, NULL, NULL },
{ L"PCI Device No. / UID Byte 3", 1, 62, L"0x%x", NULL, NULL, NULL, NULL },
{ L"PCI Function No. / UID Byte 4",1, 63, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Reserved", 1, 64, L"%x", NULL, NULL, NULL, NULL }
};

/**
This function parses the ACPI SPMI table.
When trace is enabled this function parses the SPMI table and
traces the ACPI table fields.

This function also performs validations 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
ParseAcpiSpmi (
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
if (!Trace) {
return;
}

// Dump the SPMI
ParseAcpi (
TRUE,
0,
"SPMI",
Ptr,
AcpiTableLength,
PARSER_PARAMS (SpmiParser)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
Copyright (c) 2016 - 2023, Arm Limited. All rights reserved.<BR>
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

Expand Down Expand Up @@ -75,6 +76,7 @@ ACPI_TABLE_PARSER ParserList[] = {
{ 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 },
{ EFI_ACPI_6_5_SERVER_PLATFORM_MANAGEMENT_INTERFACE_TABLE_SIGNATURE, ParseAcpiSpmi },
{ EFI_ACPI_6_2_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE, ParseAcpiSrat },
{ EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiSsdt },
{ EFI_ACPI_6_5_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE, ParseAcpiWsmt },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2016 - 2024, Arm Limited. All rights reserved.<BR>
# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down Expand Up @@ -54,6 +55,7 @@
Parsers/Rsdp/RsdpParser.c
Parsers/Slit/SlitParser.c
Parsers/Spcr/SpcrParser.c
Parsers/Spmi/SpmiParser.c
Parsers/Srat/SratParser.c
Parsers/Ssdt/SsdtParser.c
Parsers/Wsmt/WsmtParser.c
Expand Down
Loading