From: "Tomas Pilar (tpilar)" <Tomas.Pilar@arm.com>
To: <devel@edk2.groups.io>
Cc: <Sami.Mujawar@arm.com>, <nd@arm.com>, Ray Ni <ray.ni@intel.com>,
"Zhichao Gao" <zhichao.gao@intel.com>
Subject: [PATCH v2 5/8] ShellPkg/AcpiView: Refactor PrintFieldName
Date: Sun, 12 Jul 2020 11:32:12 +0100 [thread overview]
Message-ID: <20200712103215.855-6-Tomas.Pilar@arm.com> (raw)
In-Reply-To: <20200712103215.855-1-Tomas.Pilar@arm.com>
The AcpiView core method is refactored to take format
and parameters rather than a fully formatted string. This
allows for far more flexible parser writing.
Change-Id: I02c30939f2c5ad98da7174303ae241839d2c8eba
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
---
.../UefiShellAcpiViewCommandLib/AcpiParser.c | 30 ---------------
.../UefiShellAcpiViewCommandLib/AcpiParser.h | 19 ----------
.../UefiShellAcpiViewCommandLib/AcpiViewLog.c | 38 +++++++++++++++++++
.../UefiShellAcpiViewCommandLib/AcpiViewLog.h | 21 ++++++++++
.../Parsers/Dbg2/Dbg2Parser.c | 1 +
.../Parsers/Fadt/FadtParser.c | 1 +
.../Parsers/Iort/IortParser.c | 1 +
.../Parsers/Pptt/PpttParser.c | 1 +
.../Parsers/Slit/SlitParser.c | 1 +
.../Parsers/Srat/SratParser.c | 1 +
.../Parsers/Xsdt/XsdtParser.c | 1 +
11 files changed, 66 insertions(+), 49 deletions(-)
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
index b88594cf3865..54d87e2768e1 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
@@ -13,8 +13,6 @@
#include "AcpiViewConfig.h"
#include "AcpiViewLog.h"
-STATIC UINT32 gIndent;
-
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
@@ -390,34 +388,6 @@ Dump12Chars (
);
}
-/**
- This function indents and prints the ACPI table Field Name.
-
- @param [in] Indent Number of spaces to add to the global table indent.
- The global table indent is 0 by default; however
- this value is updated on entry to the ParseAcpi()
- by adding the indent value provided to ParseAcpi()
- and restored back on exit.
- Therefore the total indent in the output is
- dependent on from where this function is called.
- @param [in] FieldName Pointer to the Field Name.
-**/
-VOID
-EFIAPI
-PrintFieldName (
- IN UINT32 Indent,
- IN CONST CHAR16* FieldName
-)
-{
- Print (
- L"%*a%-*s : ",
- gIndent + Indent,
- "",
- (OUTPUT_FIELD_COLUMN_WIDTH - gIndent - Indent),
- FieldName
- );
-}
-
/**
This function is used to parse an ACPI table buffer.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 84eae61c8889..eb0c74eef144 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -204,25 +204,6 @@ Dump12Chars (
IN UINT8* Ptr
);
-/**
- This function indents and prints the ACPI table Field Name.
-
- @param [in] Indent Number of spaces to add to the global table
- indent. The global table indent is 0 by default;
- however this value is updated on entry to the
- ParseAcpi() by adding the indent value provided to
- ParseAcpi() and restored back on exit. Therefore
- the total indent in the output is dependent on from
- where this function is called.
- @param [in] FieldName Pointer to the Field Name.
-**/
-VOID
-EFIAPI
-PrintFieldName (
- IN UINT32 Indent,
- IN CONST CHAR16* FieldName
- );
-
/**
This function pointer is the template for customizing the trace output
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c
index 7ec276ac7528..18bbf67eef0a 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c
@@ -27,6 +27,7 @@ static const CHAR16* mErrorTypeDesc [ACPI_ERROR_MAX] = {
// Publicly accessible error and warning counters.
UINT32 mTableErrorCount;
UINT32 mTableWarningCount;
+UINT32 gIndent;
/**
Change the attributes of the standard output console
@@ -336,3 +337,40 @@ CheckConstraintInternal (
// Return TRUE if constraint was violated
return !Constraint;
}
+
+/**
+ This function indents and prints the ACPI table Field Name.
+
+ @param [in] Indent Number of spaces to add to the global table indent.
+ The global table indent is 0 by default; however
+ this value is updated on entry to the ParseAcpi()
+ by adding the indent value provided to ParseAcpi()
+ and restored back on exit.
+ Therefore the total indent in the output is
+ dependent on from where this function is called.
+ @param [in] FieldName Pointer to the format string for field name.
+ @param [in] ... Variable List parameters to format.
+**/
+VOID
+EFIAPI
+PrintFieldName (
+ IN UINT32 Indent,
+ IN CONST CHAR16* FieldNameFormat,
+ ...
+ )
+{
+ VA_LIST Marker;
+ CHAR16 Buffer[64];
+
+ VA_START(Marker, FieldNameFormat);
+ UnicodeVSPrint(Buffer, sizeof(Buffer), FieldNameFormat, Marker);
+ VA_END(Marker);
+
+ AcpiViewOutput (
+ L"%*a%-*s : ",
+ gIndent + Indent,
+ "",
+ (OUTPUT_FIELD_COLUMN_WIDTH - gIndent - Indent),
+ Buffer
+ );
+}
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h
index ce276ef7add2..0077646ca253 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h
@@ -40,6 +40,7 @@ typedef enum {
// Publicly accessible error and warning counters.
extern UINT32 mTableErrorCount;
extern UINT32 mTableWarningCount;
+extern UINT32 gIndent;
/**
AcpiView output and logging function. Will log the event to
@@ -171,6 +172,26 @@ CheckConstraintInternal (
!!(Constraint), \
ACPI_WARN)
+/**
+ This function indents and prints the ACPI table Field Name.
+
+ @param [in] Indent Number of spaces to add to the global table indent.
+ The global table indent is 0 by default; however
+ this value is updated on entry to the ParseAcpi()
+ by adding the indent value provided to ParseAcpi()
+ and restored back on exit.
+ Therefore the total indent in the output is
+ dependent on from where this function is called.
+ @param [in] FieldName Pointer to the format string for field name.
+ @param [in] ... Variable List parameters to format.
+**/
+VOID
+EFIAPI
+PrintFieldName (
+ IN UINT32 Indent,
+ IN CONST CHAR16* FieldNameFormat,
+ ...
+ );
// Maximum string size that can be printed
#define MAX_OUTPUT_SIZE 256
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
index 9df111ecaa7d..dd69ed6992ba 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
@@ -12,6 +12,7 @@
#include <Library/UefiLib.h>
#include "AcpiParser.h"
#include "AcpiTableParser.h"
+#include "AcpiViewLog.h"
// Local variables pointing to the table fields
STATIC CONST UINT32* OffsetDbgDeviceInfo;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
index d86718bab67d..4734864dfdcf 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
@@ -13,6 +13,7 @@
#include "AcpiParser.h"
#include "AcpiTableParser.h"
#include "AcpiView.h"
+#include "AcpiViewLog.h"
// Local variables
STATIC CONST UINT32* DsdtAddress;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
index f7447947b230..356f355939aa 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
@@ -14,6 +14,7 @@
#include "AcpiParser.h"
#include "AcpiTableParser.h"
#include "AcpiViewConfig.h"
+#include "AcpiViewLog.h"
// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
index acd2b81bb325..97a5203efb5f 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
@@ -15,6 +15,7 @@
#include "AcpiView.h"
#include "AcpiViewConfig.h"
#include "PpttParser.h"
+#include "AcpiViewLog.h"
// Local variables
STATIC CONST UINT8* ProcessorTopologyStructureType;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
index e4625ee8b139..cedfc8a71849 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
@@ -13,6 +13,7 @@
#include <Library/UefiLib.h>
#include "AcpiParser.h"
#include "AcpiTableParser.h"
+#include "AcpiViewLog.h"
// Local Variables
STATIC CONST UINT64* SlitSystemLocalityCount;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
index b9b67820b89f..568a0400bf07 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
@@ -14,6 +14,7 @@
#include "AcpiParser.h"
#include "AcpiTableParser.h"
#include "AcpiViewConfig.h"
+#include "AcpiViewLog.h"
// Local Variables
STATIC CONST UINT8* SratRAType;
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
index e39061f8e261..771c4f322b8e 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
@@ -13,6 +13,7 @@
#include <Library/PrintLib.h>
#include "AcpiParser.h"
#include "AcpiTableParser.h"
+#include "AcpiViewLog.h"
// Local variables
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
--
2.24.1.windows.2
next prev parent reply other threads:[~2020-07-12 10:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-12 10:32 [PATCH v2 0/8] ShellPkg/AcpiView: Refactor Error Logging Tomas Pilar (tpilar)
2020-07-12 10:32 ` [PATCH v2 1/8] ShellPkg/AcpiView: Extract configuration struct Tomas Pilar (tpilar)
2020-07-12 10:32 ` [PATCH v2 2/8] ShellPkg/AcpiView: Declutter error counters Tomas Pilar (tpilar)
2020-07-12 10:32 ` [PATCH v2 3/8] ShellPkg/AcpiView: Modify error message Tomas Pilar (tpilar)
2020-07-12 10:32 ` [PATCH v2 4/8] ShellPkg/AcpiView: Create a logging facility Tomas Pilar (tpilar)
2020-07-12 10:32 ` Tomas Pilar (tpilar) [this message]
2020-07-12 10:32 ` [PATCH v2 6/8] ShellPkg/AcpiView: Refactor dump helpers Tomas Pilar (tpilar)
2020-07-12 10:32 ` [PATCH v2 7/8] ShellPkg/AcpiView: Refactor AcpiView Tomas Pilar (tpilar)
2020-07-12 10:32 ` [PATCH v2 8/8] ShellPkg/AcpiView: Refactor table parsers Tomas Pilar (tpilar)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200712103215.855-6-Tomas.Pilar@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox