summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Mujawar <sami.mujawar@arm.com>2026-05-15 16:40:54 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2026-07-03 12:24:39 +0000
commitf47d5291b99095d6f01f35f18fe7f4d0c276464f (patch)
treec03f0b16719d42972673b075c729ffbea2009674
parentec44a71ba711b326be4f1d0e370a0d67668cdfa8 (diff)
downloadedk2-f47d5291b99095d6f01f35f18fe7f4d0c276464f.tar.gz
edk2-f47d5291b99095d6f01f35f18fe7f4d0c276464f.zip
ShellPkg/Acpiview: Make reserved-field validation common
Move the reserved-field validators from MpamParser.c into AcpiParser.c and expose them through AcpiParser.h so they can be reused by multiple Acpiview parsers. Update the AGDI, MPAM and WSMT parsers to use the common helpers for byte-length and bit-length reserved fields. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
-rw-r--r--ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c47
-rw-r--r--ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h30
-rw-r--r--ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Agdi/AgdiParser.c27
-rw-r--r--ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mpam/MpamParser.c55
-rw-r--r--ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c35
5 files changed, 83 insertions, 111 deletions
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
index 728d8b523a..e6a789d853 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
@@ -625,6 +625,53 @@ DumpReservedBits (
}
/**
+ This function validates reserved fields to check if they are 0.
+
+ @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
+ValidateReserved (
+ IN UINT8 *Ptr,
+ IN UINT32 Length,
+ IN VOID *Context
+ )
+{
+ while (Length > 0) {
+ if (Ptr[Length - 1] != 0) {
+ IncrementErrorCount ();
+ Print (L"\nERROR : Reserved field must be 0\n");
+ break;
+ }
+
+ Length--;
+ }
+}
+
+/**
+ This function validates bit-length reserved fields to check if they are 0.
+
+ @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
+ValidateReservedBits (
+ IN UINT8 *Ptr,
+ IN UINT32 Length,
+ IN VOID *Context
+ )
+{
+ UINT32 ByteLength;
+
+ ByteLength = (Length + 7) >> 3;
+ ValidateReserved (Ptr, ByteLength, Context);
+}
+
+/**
This function indents and prints the ACPI table Field Name.
@param [in] Indent Number of spaces to add to the global table indent.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index b1fe03b01a..9d559b39ea 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -268,6 +268,36 @@ DumpReservedBits (
);
/**
+ This function validates reserved fields to check if they are 0.
+
+ @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
+ValidateReserved (
+ IN UINT8 *Ptr,
+ IN UINT32 Length,
+ IN VOID *Context
+ );
+
+/**
+ This function validates bit-length reserved fields to check if they are 0.
+
+ @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
+ValidateReservedBits (
+ IN UINT8 *Ptr,
+ IN UINT32 Length,
+ IN VOID *Context
+ );
+
+/**
This function indents and prints the ACPI table Field Name.
@param [in] Indent Number of spaces to add to the global table
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Agdi/AgdiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Agdi/AgdiParser.c
index 253c83d8c3..8b834a2967 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Agdi/AgdiParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Agdi/AgdiParser.c
@@ -43,34 +43,11 @@ ValidateSignalingFlags (
}
/**
- Validate that the Reserved field has expected value.
-
- @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 e.g. this
- could be a pointer to the ACPI table header.
-**/
-STATIC
-VOID
-EFIAPI
-ValidateResField (
- IN UINT8 *Ptr,
- IN UINT32 Length,
- IN VOID *Context
- )
-{
- if (*Ptr != 0) {
- IncrementErrorCount ();
- Print (L"\nERROR: Reserved bits in Flags must be 0");
- }
-}
-
-/**
An ACPI_PARSER array describing the AGDI Signaling Mode Flags field.
**/
STATIC CONST ACPI_PARSER AgdiSignalingModeFlags[] = {
- { L"Signaling Mode", 2, 0, L"%u", NULL, NULL, ValidateSignalingFlags, NULL },
- { L"Reserved", 6, 2, L"%u", NULL, NULL, ValidateResField, NULL },
+ { L"Signaling Mode", 2, 0, L"%u", NULL, NULL, ValidateSignalingFlags, NULL },
+ { L"Reserved", 6, 2, NULL, DumpReservedBits, NULL, ValidateReservedBits, NULL },
};
/**
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mpam/MpamParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mpam/MpamParser.c
index 3c13de835e..f6b3a35aea 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mpam/MpamParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mpam/MpamParser.c
@@ -71,61 +71,6 @@ MpamLengthError (
}
/**
- This function validates reserved fields. Any reserved field within the MPAM
- specification must be 0.
-
- @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. For this
- particular function, context holds the size of the
- reserved field that needs to be validated.
-**/
-STATIC
-VOID
-EFIAPI
-ValidateReserved (
- IN UINT8 *Ptr,
- IN UINT32 Length,
- IN VOID *Context
- )
-{
- while (Length > 0) {
- if (Ptr[Length-1] != 0) {
- IncrementErrorCount ();
- Print (L"\nERROR : Reserved field must be 0\n");
- break;
- }
-
- Length--;
- }
-}
-
-/**
- This function validates bit-length reserved fields. Any reserved field within
- the MPAM specification must be 0.
-
- @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. For this
- particular function, context holds the size of the
- reserved field that needs to be validated.
-**/
-STATIC
-VOID
-EFIAPI
-ValidateReservedBits (
- IN UINT8 *Ptr,
- IN UINT32 Length,
- IN VOID *Context
- )
-{
- UINT32 ByteLength;
-
- ByteLength = (Length + 7) >> 3;
- ValidateReserved (Ptr, ByteLength, Context);
-}
-
-/**
This function validates the MMIO size within the MSC node body for MPAM ACPI
table. MPAM ACPI specification states that the MMIO size for an MSC having PCC
type interface should be zero.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
index 4433c047a4..b700cec49f 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
@@ -50,40 +50,13 @@ ValidateWsmtProtectionFlag (
}
/**
- This function validates the reserved bits in the WSMT Protection flag.
-
- @param [in] Ptr Pointer to the start of the buffer.
- @param [in] Length Length of the field.
- @param [in] Context Pointer to context specific information e.g. this
- could be a pointer to the ACPI table header.
-**/
-STATIC
-VOID
-EFIAPI
-ValidateReserved (
- IN UINT8 *Ptr,
- IN UINT32 Length,
- IN VOID *Context
- )
-{
- UINT32 ProtectionFlag;
-
- ProtectionFlag = *(UINT32 *)Ptr;
-
- if ((ProtectionFlag & 0xFFFFFFF8) != 0) {
- IncrementErrorCount ();
- Print (L"ERROR: Reserved bits are not zero.\n");
- }
-}
-
-/**
An ACPI_PARSER array describing the WSMT Protection flag .
**/
STATIC CONST ACPI_PARSER WsmtProtectionFlagParser[] = {
- { L"FIXED_COMM_BUFFERS ", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
- { L"COMM_BUFFER_NESTED_PTR_PROTECTION ", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
- { L"SYSTEM_RESOURCE_PROTECTION ", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
- { L"Reserved ", 29, 3, L"0x%x", NULL, NULL, ValidateReserved, NULL },
+ { L"FIXED_COMM_BUFFERS ", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
+ { L"COMM_BUFFER_NESTED_PTR_PROTECTION ", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
+ { L"SYSTEM_RESOURCE_PROTECTION ", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
+ { L"Reserved ", 29, 3, NULL, DumpReservedBits, NULL, ValidateReservedBits, NULL },
};
/**