ShellPkg/AcpiView: Update print-formatter prototype

As of now, the print-formatter implemented by the FNPTR_PRINT_FORMATTER
function pointer takes two parameters, the format string and the pointer
to the field. For cases where the print-formatter has to have access to
the length of the field, there is no clean way to currently do it. In
order to resolve this, update the print-formatter's prototype to take
the length of the field as a third parameter. This change should improve
the overall robustness and flexibility of AcpiView.

Signed-off-by: Rohit Mathew <Rohit.Mathew@arm.com>
Cc: James Morse <james.Morse@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Thomas Abraham <thomas.abraham@arm.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
Rohit Mathew 2023-08-22 14:32:52 +01:00 committed by mergify[bot]
parent 107d0c3800
commit 9e865f9579
12 changed files with 98 additions and 36 deletions

View File

@ -319,12 +319,14 @@ DumpUint64 (
@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
Dump3Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
Print (
@ -343,12 +345,14 @@ Dump3Chars (
@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
Dump4Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
Print (
@ -368,12 +372,14 @@ Dump4Chars (
@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
Dump6Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
Print (
@ -395,12 +401,14 @@ Dump6Chars (
@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
Dump8Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
Print (
@ -424,12 +432,14 @@ Dump8Chars (
@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
Dump12Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
Print (
@ -587,7 +597,7 @@ ParseAcpi (
// the Format for printing
PrintFieldName (2, Parser[Index].NameStr);
if (Parser[Index].PrintFormatter != NULL) {
Parser[Index].PrintFormatter (Parser[Index].Format, Ptr);
Parser[Index].PrintFormatter (Parser[Index].Format, Ptr, Parser[Index].Length);
} else if (Parser[Index].Format != NULL) {
switch (Parser[Index].Length) {
case 1:
@ -685,12 +695,14 @@ DumpGasStruct (
@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
DumpGas (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
DumpGasStruct (Ptr, 2, sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE));
@ -896,7 +908,7 @@ ParseAcpiBitFields (
// the Format for printing
PrintFieldName (2, Parser[Index].NameStr);
if (Parser[Index].PrintFormatter != NULL) {
Parser[Index].PrintFormatter (Parser[Index].Format, (UINT8 *)&Data);
Parser[Index].PrintFormatter (Parser[Index].Format, (UINT8 *)&Data, Parser[Index].Length);
} else if (Parser[Index].Format != NULL) {
// convert bit length to byte length
switch ((Parser[Index].Length + 7) >> 3) {

View File

@ -130,12 +130,14 @@ DumpUint64 (
@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
Dump3Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
);
/**
@ -146,12 +148,14 @@ Dump3Chars (
@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
Dump4Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
);
/**
@ -162,12 +166,14 @@ Dump4Chars (
@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
Dump6Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
);
/**
@ -178,12 +184,14 @@ Dump6Chars (
@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
Dump8Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
);
/**
@ -194,12 +202,14 @@ Dump8Chars (
@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
Dump12Chars (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
);
/**
@ -227,8 +237,9 @@ PrintFieldName (
@param [in] Format Format string for tracing the data as specified by
the 'Format' member of ACPI_PARSER.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
typedef VOID (EFIAPI *FNPTR_PRINT_FORMATTER)(CONST CHAR16 *Format, UINT8 *Ptr);
typedef VOID (EFIAPI *FNPTR_PRINT_FORMATTER)(CONST CHAR16 *Format, UINT8 *Ptr, UINT32 Length);
/**
This function pointer is the template for validating an ACPI table field.
@ -473,12 +484,14 @@ DumpGasStruct (
@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
DumpGas (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
);
/**

View File

@ -157,12 +157,14 @@ ValidateInterruptFlags (
@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
DumpVendorSpecificData (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
Print (

View File

@ -177,13 +177,15 @@ ValidateRegisterRegion (
@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.
**/
STATIC
VOID
EFIAPI
DumpInjectionInstAction (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
UINT8 InjectionAction;
@ -244,13 +246,15 @@ DumpInjectionInstAction (
@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.
**/
STATIC
VOID
EFIAPI
DumpInstruction (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
UINT8 Inst;

View File

@ -171,13 +171,15 @@ FormatByte (
@param [in] Format Optional format string for tracing the data.
@param [in] Ptr Pointer to the Action byte.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpErstAction (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
FormatByte (ErstActionTable, *Ptr, ARRAY_SIZE (ErstActionTable));
@ -188,13 +190,15 @@ DumpErstAction (
@param [in] Format Optional format string for tracing the data.
@param [in] Ptr Pointer to the Instruction byte.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpErstInstruction (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
FormatByte (ErstInstructionTable, *Ptr, ARRAY_SIZE (ErstInstructionTable));

View File

@ -169,12 +169,14 @@ STATIC CONST ACPI_PARSER FadtFlagParser[] = {
@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
DumpFadtFlags (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {

View File

@ -146,13 +146,15 @@ ValidateErrorNotificationType (
@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.
**/
STATIC
VOID
EFIAPI
DumpSourceFlags (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
@ -176,13 +178,15 @@ DumpSourceFlags (
@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.
**/
STATIC
VOID
EFIAPI
DumpErrorNotificationType (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
@ -202,13 +206,15 @@ DumpErrorNotificationType (
@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.
**/
STATIC
VOID
EFIAPI
DumpErrorNotificationCwe (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
@ -433,13 +439,15 @@ ValidateRecordCount (
@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.
**/
STATIC
VOID
EFIAPI
DumpNotificationStructure (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
UINT32 Offset;
@ -466,13 +474,15 @@ DumpNotificationStructure (
from HestTable.
@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.
**/
STATIC
VOID
EFIAPI
DumpPciBus (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {

View File

@ -111,13 +111,15 @@ ValidateCacheAttributes (
@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.
**/
STATIC
VOID
EFIAPI
DumpCacheAttributes (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES *

View File

@ -25,7 +25,8 @@ VOID
EFIAPI
DumpHpetPageProtectionFlag (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
@ -72,7 +73,8 @@ VOID
EFIAPI
DumpHpetFlag (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
@ -102,7 +104,8 @@ VOID
EFIAPI
DumpCounterSize (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
@ -166,7 +169,8 @@ VOID
EFIAPI
DumpHpetEventTimerBlockId (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {

View File

@ -270,12 +270,14 @@ STATIC CONST ACPI_PARSER LocalApicFlags[] = {
@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
DumpLocalApicBitFlags (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {

View File

@ -81,13 +81,15 @@ ValidateSratDeviceHandleType (
@param [in] Format Format string for tracing the data.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpSratPciBdfNumber (
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
@ -169,13 +171,15 @@ STATIC CONST ACPI_PARSER SratDeviceHandlePciParser[] = {
@param [in] Format Format string for tracing the data.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpSratDeviceHandle (
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (SratDeviceHandleType == NULL) {
@ -212,13 +216,15 @@ DumpSratDeviceHandle (
@param [in] Format Format string for tracing the data.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpSratApicProximity (
IN CONST CHAR16 *Format,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
UINT32 ProximityDomain;

View File

@ -97,7 +97,8 @@ VOID
EFIAPI
DumpWsmtProtectionFlag (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {