From 2a219e196d7cf6d6df5a6e8856549607e9c0e5ef Mon Sep 17 00:00:00 2001 From: Krzysztof Koch Date: Thu, 18 Jul 2019 18:05:01 -0700 Subject: [PATCH] ShellPkg: acpiview: GTDT: Remove redundant forward declarations Remove redundant forward function declarations by repositioning blocks of code. This way the code structure is consistent across ACPI table parsers and the code becomes more concise. Replace multple use of literal values for GT Block Timer Frame count/number validation with a macro definition. Signed-off-by: Krzysztof Koch Reviewed-by: Jaben Carsey Reviewed-by: Sami Mujawar Reviewed-by: Alexei Fedorov Reviewed-by: Zhichao Gao --- .../Parsers/Gtdt/GtdtParser.c | 91 +++++++------------ 1 file changed, 33 insertions(+), 58 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c index 3b05ff3015..1e5b5764f5 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c @@ -13,6 +13,9 @@ #include "AcpiParser.h" #include "AcpiTableParser.h" +// "The number of GT Block Timers must be less than or equal to 8" +#define GT_BLOCK_TIMER_COUNT_MAX 8 + // Local variables STATIC CONST UINT32* GtdtPlatformTimerCount; STATIC CONST UINT32* GtdtPlatformTimerOffset; @@ -36,7 +39,21 @@ EFIAPI ValidateGtBlockTimerCount ( IN UINT8* Ptr, IN VOID* Context - ); + ) +{ + UINT32 BlockTimerCount; + + BlockTimerCount = *(UINT32*)Ptr; + + if (BlockTimerCount > GT_BLOCK_TIMER_COUNT_MAX) { + IncrementErrorCount (); + Print ( + L"\nERROR: Timer Count = %d. Max Timer Count is %d.", + BlockTimerCount, + GT_BLOCK_TIMER_COUNT_MAX + ); + } +} /** This function validates the GT Frame Number. @@ -51,7 +68,21 @@ EFIAPI ValidateGtFrameNumber ( IN UINT8* Ptr, IN VOID* Context - ); + ) +{ + UINT8 FrameNumber; + + FrameNumber = *(UINT8*)Ptr; + + if (FrameNumber >= GT_BLOCK_TIMER_COUNT_MAX) { + IncrementErrorCount (); + Print ( + L"\nERROR: GT Frame Number = %d. GT Frame Number must be in range 0-%d.", + FrameNumber, + GT_BLOCK_TIMER_COUNT_MAX - 1 + ); + } +} /** An ACPI_PARSER array describing the ACPI GTDT Table. @@ -134,62 +165,6 @@ STATIC CONST ACPI_PARSER SBSAGenericWatchdogParser[] = { {L"Watchdog Timer Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL} }; -/** - This function validates the GT Block timer count. - - @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 -ValidateGtBlockTimerCount ( - IN UINT8* Ptr, - IN VOID* Context - ) -{ - UINT32 BlockTimerCount; - - BlockTimerCount = *(UINT32*)Ptr; - - if (BlockTimerCount > 8) { - IncrementErrorCount (); - Print ( - L"\nERROR: Timer Count = %d. Max Timer Count is 8.", - BlockTimerCount - ); - } -} - -/** - This function validates the GT Frame Number. - - @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 -ValidateGtFrameNumber ( - IN UINT8* Ptr, - IN VOID* Context - ) -{ - UINT8 FrameNumber; - - FrameNumber = *(UINT8*)Ptr; - - if (FrameNumber > 7) { - IncrementErrorCount (); - Print ( - L"\nERROR: GT Frame Number = %d. GT Frame Number must be in range 0-7.", - FrameNumber - ); - } -} - /** This function parses the Platform GT Block.