Re: [edk2-devel] [PATCH v4 01/15] DynamicTablesPkg: Definition for HwInfoParser interface

2021-12-14 Thread Joey Gouly
Hi Pierre,

> From: Pierre Gondois 
> 
> Hardware information parser is an optional module defined
> by the Dynamic Tables Framework. It can either parse an
> XML, a Device Tree or a Json file containing the platform
> hardware information to populate the platform information
> repository.
> 
> The Configuration Manager can then utilise this information
> to generate ACPI tables for the platform.
> 
> Therefore, define an interface for the HwInfoParser library
> class.
> 

Reviewed-by: Joey Gouly 

Thanks,
Joey


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84820): https://edk2.groups.io/g/devel/message/84820
Mute This Topic: https://groups.io/mt/87608902/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v1 9/9] ArmVirtPkg: Kvmtool: Add RNG support using FW-TRNG interface

2021-10-01 Thread Joey Gouly
Hi Sami,

>
> The EFI_RNG_PROTOCOL published by RngDxe has been updated to
> implement the EFI_RNG_ALGORITHM_RAW using the Arm FW-TRNG
> interface to provide access to entropy.
>
> Therefore, enable EFI_RNG_PROTOCOL for the Kvmtool guest/virtual
> firmware.
>
> Signed-off-by: Sami Mujawar 
> ---
>  ArmVirtPkg/ArmVirtKvmTool.dsc | 10 ++
>  ArmVirtPkg/ArmVirtKvmTool.fdf |  5 +
>  2 files changed, 15 insertions(+)
>

Tested on Juno running kvmtool.

Tested-by: Joey Gouly 

Thanks,
Joey


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81372): https://edk2.groups.io/g/devel/message/81372
Mute This Topic: https://groups.io/mt/85976759/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH edk2-platforms v1 2/2] Platform/ARM/Juno: Add RNG support using FW-TRNG interface

2021-10-01 Thread Joey Gouly
Hi Sami,

> TF-A for Juno has been updated to implement the Arm FW-TRNG interface
> that can be used to access entropy from the TRNG hardware on Juno.
>
> Similarly, the EFI_RNG_PROTOCOL in RngDxe has been updated to add
> EFI_RNG_ALGORITHM_RAW support using the FW-TRNG interface.
>
> Therefore, enable the EFI_RNG_PROTOCOL for Juno platform.
>
> Signed-off-by: Sami Mujawar 
> ---
>  Platform/ARM/JunoPkg/ArmJuno.dsc | 10 +-
>  Platform/ARM/JunoPkg/ArmJuno.fdf |  7 ++-
>  2 files changed, 15 insertions(+), 2 deletions(-)
>

Tested on Juno.

Tested-by: Joey Gouly 

Thanks,
Joey
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81371): https://edk2.groups.io/g/devel/message/81371
Mute This Topic: https://groups.io/mt/85977237/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v1 06/10] DynamicTablesPkg: Add Configuration Manager Object parser

2021-09-29 Thread Joey Gouly
Hi again,

Replies inline,

>
> Hi Joey,
> Thanks for the review, I answered inline:
>
>
> On 9/24/21 9:56 AM, Joey Gouly wrote:
> > Hi,
> >
> > This looks good to me!
> >
> > [...]
> >
> >> +
> >> +/** A parser for EArmObjFixedFeatureFlags.
> >> +*/
> >> +STATIC CONST CM_OBJ_PARSER CmArmFixedFeatureFlagsParser[] = {
> >> +  {"Flags", 4, "0x%x", NULL}
> >> +};
> >> +
> >> +/** A parser for EArmObjItsGroup.
> >> +*/
> >> +STATIC CONST CM_OBJ_PARSER CmArmItsGroupNodeParser[] = {
> >> +  {"GTBlockTimerFrameToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL},
> > This should just be Token, not GTBlockTimerFrameToken.
>
>
> The name of the field is 'GTBlockTimerFrameToken', cf
> https://github.com/tianocore/edk2/blob/master/DynamicTablesPkg/Include/ArmNameSpaceObjects.h#L394
> I am not sure I understand why this should 'Token' instead.

You linked to the `CmArmGTBlockInfo` struct, but I was talking about 
`CmArmItsGroupNode`:
https://github.com/tianocore/edk2/blob/master/DynamicTablesPkg/Include/ArmNameSpaceObjects.h#L464

>
> >
> >> +  {"ItsIdCount", 4, "0x%x", NULL},
> >> +  {"ItsIdToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}
> >> +};
> >> +
> > [...]
> >
> >> diff --git 
> >> a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.h
> >>  
> >> b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.h
> >> new file mode 100644
> >> index ..e229df7095d9
> >> --- /dev/null
> >> +++ 
> >> b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.h
> > [...]
> >
> >> +/**
> >> +  The CM_OBJ_PARSER structure describes the fields of an CmObject and
> >> +  provides means for the parser to interpret and trace appropriately.
> >> +
> >> +  ParseAcpi() uses the format string specified by 'Format' for tracing
> >> +  the field data.
> >> +*/
> >> +typedef struct CmObjParser CM_OBJ_PARSER;
> >> +struct CmObjParser {
> >> +
> >> +  /// String describing the Cm Object
> >> +  CONST CHAR8*NameStr;
> >> +
> >> +  /// The length of the field.
> >> +  UINT32  Length;
> >> +
> >> +  /// Optional Print() style format string for tracing the data. If not
> >> +  /// used this must be set to NULL.
> >> +  CONST CHAR8*Format;
> >> +
> >> +  /// Optional pointer to a print formatter function which
> >> +  /// is typically used to trace complex field information.
> >> +  /// If not used this must be set to NULL.
> >> +  /// The Format string is passed to the PrintFormatter function
> >> +  /// but may be ignored by the implementation code.
> >> +  FNPTR_PRINT_FORMATTER   PrintFormatter;
> >> +
> >> +  /// Optional pointer to print the fields of another CM_OBJ_PARSER
> >> +  /// structure. This is useful to print sub-structures.
> >> +  CONST CM_OBJ_PARSER *SubObjParser;
> >> +
> >> +  /// Count of items in the SubObj.
> >> +  UINTN   SubObjItemCount;
> > The SubObjParser doesn't actually seem to be used by any of the objects? 
> > (Unless I misread when reading the list of them..)
>
>
> The SubObjParser field is effectively not currently used. It will be
> used in a later patch,
> cf the 'UsageCounterRegister' field of
> https://edk2.groups.io/g/devel/message/76954
>
Ok, makes sense!

Thanks,
Joey
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81288): https://edk2.groups.io/g/devel/message/81288
Mute This Topic: https://groups.io/mt/83735189/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v1 06/10] DynamicTablesPkg: Add Configuration Manager Object parser

2021-09-24 Thread Joey Gouly
Hi,

This looks good to me!

[...]

> +
> +/** A parser for EArmObjFixedFeatureFlags.
> +*/
> +STATIC CONST CM_OBJ_PARSER CmArmFixedFeatureFlagsParser[] = {
> +  {"Flags", 4, "0x%x", NULL}
> +};
> +
> +/** A parser for EArmObjItsGroup.
> +*/
> +STATIC CONST CM_OBJ_PARSER CmArmItsGroupNodeParser[] = {
> +  {"GTBlockTimerFrameToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL},

This should just be Token, not GTBlockTimerFrameToken.

> +  {"ItsIdCount", 4, "0x%x", NULL},
> +  {"ItsIdToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}
> +};
> +

[...]

> diff --git 
> a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.h
>  
> b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.h
> new file mode 100644
> index ..e229df7095d9
> --- /dev/null
> +++ 
> b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.h

[...]

> +/**
> +  The CM_OBJ_PARSER structure describes the fields of an CmObject and
> +  provides means for the parser to interpret and trace appropriately.
> +
> +  ParseAcpi() uses the format string specified by 'Format' for tracing
> +  the field data.
> +*/
> +typedef struct CmObjParser CM_OBJ_PARSER;
> +struct CmObjParser {
> +
> +  /// String describing the Cm Object
> +  CONST CHAR8*NameStr;
> +
> +  /// The length of the field.
> +  UINT32  Length;
> +
> +  /// Optional Print() style format string for tracing the data. If not
> +  /// used this must be set to NULL.
> +  CONST CHAR8*Format;
> +
> +  /// Optional pointer to a print formatter function which
> +  /// is typically used to trace complex field information.
> +  /// If not used this must be set to NULL.
> +  /// The Format string is passed to the PrintFormatter function
> +  /// but may be ignored by the implementation code.
> +  FNPTR_PRINT_FORMATTER   PrintFormatter;
> +
> +  /// Optional pointer to print the fields of another CM_OBJ_PARSER
> +  /// structure. This is useful to print sub-structures.
> +  CONST CM_OBJ_PARSER *SubObjParser;
> +
> +  /// Count of items in the SubObj.
> +  UINTN   SubObjItemCount;

The SubObjParser doesn't actually seem to be used by any of the objects? 
(Unless I misread when reading the list of them..)

> +
> +  /// Count of items
> +  UINTN ItemCount;
> +} CM_OBJ_PARSER_ARRAY;
> +
> +#endif // CONFIGURATION_MANAGER_OBJECT_PARSER_H_
> diff --git 
> a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf 
> b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
> index 5435f74aa0b8..abbf4bc38cab 100644
> --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
> +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
> @@ -15,6 +15,8 @@ [Defines]
>LIBRARY_CLASS  = TableHelperLib
>
>  [Sources]
> +  ConfigurationManagerObjectParser.c
> +  ConfigurationManagerObjectParser.h
>TableHelper.c
>
>  [Packages]

Need to update the copyright year.

Otherwise:
  Reviewed-by: Joey Gouly 

Thanks,
Joey
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81073): https://edk2.groups.io/g/devel/message/81073
Mute This Topic: https://groups.io/mt/83735189/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 3/5] ShellPkg: add a Graph option to the Parser Flags

2021-09-16 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This option informs the parser to generate a dot graph of a table.
This can be useful to understand or debug a table, such as the PPTT
table.

Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h| 
 2 ++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h| 
 3 ++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c  | 
 9 +++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c   | 
24 +---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni | 
 9 ++--
 5 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 
b078c0b99335ba28f7589cac6b0a4190d9a6c3b5..9a67fe084327434bf21b37b3089779468edfb0f1
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -20,11 +20,13 @@
   Flags for the parser.
 */
 #define PARSE_FLAGS_TRACE   BIT0
+#define PARSE_FLAGS_GRAPH   BIT1
 
 /**
   Helper macros to test parser flags.
 */
 #define IS_TRACE_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_TRACE) != 0)
+#define IS_GRAPH_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_GRAPH) != 0)
 
 /**
   This function increments the ACPI table error counter.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
index 
2db4a65415d8f9e70686cb2cc432862ab4e4c2dd..262302a15cbbe04a228fd55e523930fb76bcf6a8
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for 'acpiview' configuration.
 
-  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -106,6 +106,7 @@ typedef enum {
   ReportSelected, ///< Report Selected table.
   ReportTableList,///< Report List of tables.
   ReportDumpBinFile,  ///< Dump selected table to a file.
+  ReportDotGraph, ///< Create Dot Graph for selected compatible table.
   ReportMax,
 } EREPORT_OPTION;
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 
db7b2e2a30525cc85a333b93f5eb97ec3a517b37..1155b2f3f411247c866f635fb666dd76455f18a4
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -192,6 +192,12 @@ ProcessTableReportOptions (
 DumpAcpiTableToFile (TablePtr, Length);
   }
   break;
+case ReportDotGraph:
+  if (Signature == SelectedTable->Type) {
+SelectedTable->Found = TRUE;
+ParseFlags |= PARSE_FLAGS_GRAPH;
+  }
+  break;
 case ReportMax:
   // We should never be here.
   // This case is only present to prevent compiler warning.
@@ -340,7 +346,8 @@ AcpiView (
 
   ReportOption = GetReportOption ();
   if (ReportTableList != ReportOption) {
-if (((ReportSelected == ReportOption)  ||
+if (((ReportSelected == ReportOption) ||
+ (ReportDotGraph == ReportOption) ||
  (ReportDumpBinFile == ReportOption)) &&
 (!SelectedTable->Found)) {
   Print (L"\nRequested ACPI Table not found.\n");
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index 
b30ed3fc8597b229dd15b6ad4f2aab2e3d0ca583..d837b390938f3c3bc5cb90c1161e2feeb1ed6a6b
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -1,7 +1,7 @@
 /** @file
   Main file for 'acpiview' Shell command function.
 
-  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -34,6 +34,7 @@ EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-q", TypeFlag},
   {L"-d", TypeFlag},
+  {L"-g", TypeFlag},
   {L"-h", TypeFlag},
   {L"-l", TypeFlag},
   {L"-s", TypeValue},
@@ -293,6 +294,18 @@ ShellCommandRunAcpiView (
   L"-d"
   );
 ShellStatus = SHELL_INVALID_PARAMETER;
+} else if (ShellCommandLineGetFlag (Package, L"-g") &&
+   !ShellCommandLineGetFlag (Package, L"-s")) {
+Shel

[edk2-devel] [PATCH v2 0/5] Dot graph generator for PPTT

2021-09-16 Thread Joey Gouly
This series adds functionality to print a dot graph of a PPTT table.
This helps with understanding and debugging PPTT tables.
The dot graph generator functionality is generic and could be used by
other tables that would benefit from graph output.

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

The changes can be seen at 
https://github.com/jgouly/edk2/tree/1484_pptt_dot_graph_v2

Changes since v1:
  # Fixed errors found by CI
  # Rebased onto latest master branch

Marc Moisson-Franckhauser (5):
  ShellPkg: Replace 'Trace' parameter with 'ParseFlags'
  ShellPkg: add a helper function for getting a new file name
  ShellPkg: add a Graph option to the Parser Flags
  ShellPkg: add dot file generator functions
  ShellPkg: add PPTT dot file genration

 .../UefiShellAcpiViewCommandLib.inf   |   4 +-
 .../UefiShellAcpiViewCommandLib/AcpiParser.h  |  79 +++--
 .../AcpiTableParser.h |   6 +-
 .../UefiShellAcpiViewCommandLib/AcpiView.h|  25 +-
 .../AcpiViewConfig.h  |   3 +-
 .../DotGenerator.h| 101 +++
 .../AcpiTableParser.c |  20 +-
 .../UefiShellAcpiViewCommandLib/AcpiView.c| 117 +--
 .../DotGenerator.c| 283 +
 .../Parsers/Bgrt/BgrtParser.c |  10 +-
 .../Parsers/Dbg2/Dbg2Parser.c |   8 +-
 .../Parsers/Dsdt/DsdtParser.c |   8 +-
 .../Parsers/Facs/FacsParser.c |  10 +-
 .../Parsers/Fadt/FadtParser.c |  27 +-
 .../Parsers/Gtdt/GtdtParser.c |   8 +-
 .../Parsers/Iort/IortParser.c |   8 +-
 .../Parsers/Madt/MadtParser.c |   8 +-
 .../Parsers/Mcfg/McfgParser.c |   8 +-
 .../Parsers/Pptt/PpttParser.c | 285 +++---
 .../Parsers/Rsdp/RsdpParser.c |  10 +-
 .../Parsers/Slit/SlitParser.c |   8 +-
 .../Parsers/Spcr/SpcrParser.c |   8 +-
 .../Parsers/Srat/SratParser.c |   8 +-
 .../Parsers/Ssdt/SsdtParser.c |   8 +-
 .../Parsers/Xsdt/XsdtParser.c |  10 +-
 .../UefiShellAcpiViewCommandLib.c |  24 +-
 .../UefiShellAcpiViewCommandLib.uni   |   9 +-
 27 files changed, 914 insertions(+), 189 deletions(-)
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c

-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80816): https://edk2.groups.io/g/devel/message/80816
Mute This Topic: https://groups.io/mt/85653268/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 1/5] ShellPkg: Replace 'Trace' parameter with 'ParseFlags'

2021-09-16 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This is preparation for adding a second flag to the parsers.

Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h  | 77 
+++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h |  6 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c | 20 
++---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c| 28 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Bgrt/BgrtParser.c | 10 +--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dsdt/DsdtParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c | 10 +--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c | 27 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 47 
+++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 10 +--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ssdt/SsdtParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c | 10 +--
 20 files changed, 179 insertions(+), 146 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 
0b7726b9d5807ad2f5c5447408c4c5451718938b..b078c0b99335ba28f7589cac6b0a4190d9a6c3b5
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for ACPI parser
 
-  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -16,6 +16,16 @@
 /// that allows us to process the log options.
 #define RSDP_TABLE_INFO  SIGNATURE_32('R', 'S', 'D', 'P')
 
+/**
+  Flags for the parser.
+*/
+#define PARSE_FLAGS_TRACE   BIT0
+
+/**
+  Helper macros to test parser flags.
+*/
+#define IS_TRACE_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_TRACE) != 0)
+
 /**
   This function increments the ACPI table error counter.
 **/
@@ -489,7 +499,7 @@ ParseAcpiAest (
 
   This function also performs validation of the ACPI table fields.
 
-  @param [in] Trace  If TRUE, trace the ACPI fields.
+  @param [in] ParseFlags Flags describing what the parser needs to do.
   @param [in] PtrPointer to the start of the buffer.
   @param [in] AcpiTableLengthLength of the ACPI table.
   @param [in] AcpiTableRevision  Revision of the ACPI table.
@@ -497,7 +507,7 @@ ParseAcpiAest (
 VOID
 EFIAPI
 ParseAcpiBgrt (
-  IN BOOLEAN Trace,
+  IN UINT8   ParseFlags,
   IN UINT8*  Ptr,
   IN UINT32  AcpiTableLength,
   IN UINT8   AcpiTableRevision
@@ -510,7 +520,7 @@ ParseAcpiBgrt (
 
   This function also performs validation of the ACPI table fields.
 
-  @param [in] Trace  If TRUE, trace the ACPI fields.
+  @param [in] ParseFlags Flags describing what the parser needs to do.
   @param [in] PtrPointer to the start of the buffer.
   @param [in] AcpiTableLengthLength of the ACPI table.
   @param [in] AcpiTableRevision  Revision of the ACPI table.
@@ -518,7 +528,7 @@ ParseAcpiBgrt (
 VOID
 EFIAPI
 ParseAcpiDbg2 (
-  IN BOOLEAN Trace,
+  IN UINT8   ParseFlags,
   IN UINT8*  Ptr,
   IN UINT32  AcpiTableLength,
   IN UINT8   AcpiTableRevision
@@ -531,7 +541,7 @@ ParseAcpiDbg2 (
   For the DSDT table only the ACPI header fields are parsed and
   traced.
 
-  @param [in] Trace  If TRUE, trace the ACPI fields.
+  @param [in] ParseFlags Flags describing what the parser needs to do.
   @param [in] PtrPointer to the start of the buffer.
   @param [in] AcpiTableLengthLength of the ACPI table.
   @param [in] AcpiTableRevision  Revision of the ACPI table.
@@ -539,7 +549,7 @@ ParseAcpiDbg2 (
 VOID
 EFIAPI
 ParseAcpiDsdt (
-  IN BOOLEAN Trace,
+  IN UINT8   ParseFlags,
   IN UINT8*  Ptr,
   IN UINT32  AcpiTableLength,
   IN UINT8   AcpiTableRevision
@@ -552,7 +562,7 @@ ParseAcpiDsdt (
 
   This function also performs validation of the ACPI table fields.
 
-  @param [in] Trace  If TRUE, t

[edk2-devel] [PATCH v2 4/5] ShellPkg: add dot file generator functions

2021-09-16 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

These can be used to generate dot files, that can be used to visualise
graphs in tables, such as PPTT.

Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 
  4 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h  | 
101 +++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c  | 
283 
 3 files changed, 387 insertions(+), 1 deletion(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index 
63fc5a1281a894841dac704484c3d4f9481edb46..ffe4979b3ac5d0120bcf678cf7823afac6674e4f
 100644
--- 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -1,7 +1,7 @@
 ##  @file
 # Provides Shell 'acpiview' command functions
 #
-# Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -27,6 +27,8 @@ [Sources.common]
   AcpiView.h
   AcpiViewConfig.c
   AcpiViewConfig.h
+  DotGenerator.c
+  DotGenerator.h
   Parsers/Aest/AestParser.c
   Parsers/Bgrt/BgrtParser.c
   Parsers/Dbg2/Dbg2Parser.c
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h
new file mode 100644
index 
..8e196eee75417c0a422023c00b043441076ac599
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h
@@ -0,0 +1,101 @@
+/** @file
+  Header file for Dot File Generation
+
+  Copyright (c) 2021, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef DOT_GENERATOR_H_
+#define DOT_GENERATOR_H_
+
+#include 
+
+#define DOT_COLOR_MASK0b111
+// Flags for color of arrow or node.
+#define DOT_COLOR_BLACK   0b000 // default
+#define DOT_COLOR_GRAY0b001
+#define DOT_COLOR_BLUE0b010
+#define DOT_COLOR_YELLOW  0b011
+#define DOT_COLOR_RED 0b100
+
+#define DOT_ARROW_TYPE_MASK   0b1000
+// Flags for style of arrow.
+#define DOT_ARROW_FULL0b // default
+#define DOT_ARROW_DOTTED  0b1000
+
+// Flag for reversing how the nodes will be ranked and displayed.
+#define DOT_ARROW_RANK_REVERSE0b1
+
+#define DOT_BOX_TYPE_MASK 0b110
+// Flag for shape of box
+#define DOT_BOX_SQUARE0b000 // default
+#define DOT_BOX_DIAMOND   0b010
+
+// Flag for adding the node's ID to the end of the label.
+#define DOT_BOX_ADD_ID_TO_LABEL   0b1000
+
+// Valid flags for DotAddNode.
+#define DOT_BOX_FLAGS_MASK(DOT_COLOR_MASK |\
+   DOT_BOX_TYPE_MASK |\
+   DOT_BOX_ADD_ID_TO_LABEL)
+// Valid flags for DotAddLink.
+#define DOT_ARROW_FLAGS_MASK  (DOT_COLOR_MASK |\
+   DOT_ARROW_TYPE_MASK |\
+   DOT_ARROW_RANK_REVERSE)
+
+
+/**
+  Opens a new dot file and writes a dot directional graph.
+
+  @param [in] FileNameNull terminated unicode string.
+**/
+SHELL_FILE_HANDLE
+DotOpenNewFile (
+  IN CHAR16* FileName
+  );
+
+/**
+  Writes a dot graph footer and closes the dot file.
+
+  @param [in] DotFileHandle  The handle of the dot file.
+**/
+VOID
+DotCloseFile (
+  SHELL_FILE_HANDLE DotFileHandle
+  );
+
+/**
+  Writes a line in the previously opened dot file describing a
+  new node.
+
+  @param [in] DotFileHandle  The handle of the dot file.
+  @param [in] Id A unique identifier for the node.
+  @param [in] Flags  Flags describing the node's characteristics.
+  @param [in] Label  Label to be shown on the graph node.
+**/
+VOID
+DotAddNode (
+  SHELL_FILE_HANDLE DotFileHandle,
+  IN UINT32 Id,
+  IN UINT16 Flags,
+  IN CONST CHAR16*  Label
+  );
+
+/**
+  Writes a line in the previously opened dot file describing a
+  new link between two nodes.
+
+  @param [in] DotFileHandle  The handle of the dot file.
+  @param [in] IdSource   An identifier for the source node of the link.
+  @param [in] IdTarget   An identifier for the target node of the link.
+  @param [in] Flags  Flags describing the node's characteristics.
+**/
+VOID
+DotAddLink (
+  SHELL_FILE_HANDLE DotFileHandle,
+  IN UINT32 IdSource,
+  IN UINT32 IdTarget,
+  IN UINT16 Flags
+  );
+
+#endif // DOT_GENERATOR_H_
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c
new file mode 100644
index 

[edk2-devel] [PATCH v2 5/5] ShellPkg: add PPTT dot file genration

2021-09-16 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This generates a dot file from the PPTT table that can be used to
visualise the topology of the CPUs and Caches.

Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 240 
++--
 1 file changed, 218 insertions(+), 22 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
index 
538b6a69350d75ccbf36b86fff115255e77437c7..b52bd532b846b9cec0ca315b043beff95df40bd5
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
@@ -15,11 +15,23 @@
 #include "AcpiView.h"
 #include "AcpiViewConfig.h"
 #include "PpttParser.h"
+#include "DotGenerator.h"
 
 // Local variables
 STATIC CONST UINT8*  ProcessorTopologyStructureType;
 STATIC CONST UINT8*  ProcessorTopologyStructureLength;
+
 STATIC CONST UINT32* NumberOfPrivateResources;
+STATIC CONST UINT32* ProcessorHierarchyParent;
+STATIC CONST EFI_ACPI_6_3_PPTT_STRUCTURE_PROCESSOR_FLAGS* ProcStructFlags;
+STATIC CONST UINT32* NextLevelOfCache;
+STATIC CONST EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE_ATTRIBUTES* CacheAttributes;
+STATIC CONST UINT32* CacheSize;
+
+STATIC CONST UINT8*  PpttStartPointer;
+
+STATIC SHELL_FILE_HANDLE mDotFileHandle;
+
 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
 
 /**
@@ -198,8 +210,9 @@ STATIC CONST ACPI_PARSER 
ProcessorHierarchyNodeStructureParser[] = {
   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
 
-  {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
-  {L"Parent", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
+  {L"Flags", 4, 4, L"0x%x", NULL, (VOID**), NULL, NULL},
+  {L"Parent", 4, 8, L"0x%x", NULL,
+(VOID**), NULL, NULL},
   {L"ACPI Processor ID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
   {L"Number of private resources", 4, 16, L"%d", NULL,
(VOID**), NULL, NULL}
@@ -214,11 +227,13 @@ STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = {
   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
 
   {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
-  {L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
-  {L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
+  {L"Next Level of Cache", 4, 8, L"0x%x", NULL,
+(VOID**), NULL, NULL},
+  {L"Size", 4, 12, L"0x%x", NULL, (VOID**), NULL, NULL},
   {L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, 
NULL},
   {L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, 
NULL},
-  {L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL},
+  {L"Attributes", 1, 21, L"0x%x", NULL, (VOID**),
+ValidateCacheAttributes, NULL},
   {L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL}
 };
 
@@ -257,6 +272,7 @@ DumpProcessorHierarchyNodeStructure (
   UINT32 Offset;
   UINT32 Index;
   CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
+  CONST UINT8* TypePtr;
 
   Offset = ParseAcpi (
  IS_TRACE_FLAG_SET (ParseFlags),
@@ -291,26 +307,67 @@ DumpProcessorHierarchyNodeStructure (
 return;
   }
 
-  Index = 0;
+  if (IS_GRAPH_FLAG_SET (ParseFlags)) {
+if (ProcStructFlags->ProcessorIsAThread) {
+  UnicodeSPrint(Buffer, sizeof (Buffer), L"Thread");
+} else if (ProcStructFlags->NodeIsALeaf) {
+  UnicodeSPrint(Buffer, sizeof (Buffer), L"Core");
+} else if (ProcStructFlags->PhysicalPackage) {
+  UnicodeSPrint(Buffer, sizeof (Buffer), L"Physical\\nPackage");
+} else {
+  UnicodeSPrint(Buffer, sizeof (Buffer), L"Cluster");
+}
+
+DotAddNode (
+  mDotFileHandle,
+  (UINT32)(Ptr - PpttStartPointer),
+  DOT_BOX_SQUARE | DOT_COLOR_BLUE | DOT_BOX_ADD_ID_TO_LABEL,
+  Buffer
+  );
+
+// Add link to parent node.
+if (*ProcessorHierarchyParent != 0) {
+  DotAddLink (
+mDotFileHandle,
+(UINT32)(Ptr - PpttStartPointer),
+*ProcessorHierarchyParent,
+0x0
+);
+}
+  }
 
   // Parse the specified number of private resource references or the Processor
   // Hierarchy Node length. Whichever is minimum.
-  while (Index < *NumberOfPrivateResources) {
-UnicodeSPrint (
-  Buffer,
-  sizeof (Buffer),
-  L"Private resources [%d]",
-  Index
-  );
+  for (Index = 0; Index < 

[edk2-devel] [PATCH v2 2/5] ShellPkg: add a helper function for getting a new file name

2021-09-16 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This new helper will not overwrite existing files, by appending a number
to the end of the filename.

Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h | 25 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 80 

 2 files changed, 91 insertions(+), 14 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
index 
d5b95f5ee707de18be1879b3cd235d6c5db11d9f..ae8a67b7681033d66d068341ae489ded67de8b44
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
@@ -1,12 +1,13 @@
 /** @file
   Header file for AcpiView
 
-  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #ifndef ACPIVIEW_H_
 #define ACPIVIEW_H_
+#include 
 
 /**
   A macro to define the max file name length
@@ -23,6 +24,28 @@
 **/
 #define RSDP_LENGTH_OFFSET   20
 
+/**
+  This function finds a filename not already used by adding a number in between
+  the BaseFileName and the extension.
+
+  Make sure the buffer FileName is big enough before calling the function. A
+  size of MAX_FILE_NAME_LEN is recommended.
+
+  @param [in]  BaseFileName  Start of the desired file name.
+  @param [in]  Extension Extension of the desired file name
+ (without '.').
+  @param [in, out] FileName  Preallocated buffer for the returned file
+ name.
+  @param [in]  FileNameBufferLen Size of FileName buffer..
+**/
+EFI_STATUS
+GetNewFileName (
+  IN CONST CHAR16* BaseFileName,
+  IN CONST CHAR16* Extension,
+  IN OUT   CHAR16* FileName,
+  IN   UINT32  FileNameBufferLen
+  );
+
 /**
   This function resets the ACPI table error counter to Zero.
 **/
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 
a4242ba9d99b05d07c829520c4011439445aadb0..db7b2e2a30525cc85a333b93f5eb97ec3a517b37
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -27,8 +27,55 @@
 #include "Arm/SbbrValidator.h"
 #endif
 
-STATIC UINT32 mTableCount;
-STATIC UINT32 mBinTableCount;
+STATIC UINT32  mTableCount;
+
+/**
+  This function finds a filename not already used by adding a number in between
+  The BaseFileName and the extension.
+
+  Make sure the buffer FileName is big enough before calling the function. A
+  size of MAX_FILE_NAME_LEN is recommended.
+
+  @param [in]  BaseFileName  Start of the desired file name.
+  @param [in]  Extension Extension of the desired file name
+ (without '.').
+  @param [in, out] FileName  Preallocated buffer for the returned file
+ name.
+  @param [in]  FileNameBufferLen Size of FileName buffer..
+**/
+EFI_STATUS
+GetNewFileName (
+  IN CONST CHAR16* BaseFileName,
+  IN CONST CHAR16* Extension,
+  IN OUT   CHAR16* FileName,
+  IN   UINT32  FileNameBufferLen
+  )
+{
+  UINT16Index;
+  EFI_STATUSStatus;
+  SHELL_FILE_HANDLE tmpFileHandle;
+  for (Index = 0; Index <= 99; Index++) {
+UnicodeSPrint(
+  FileName,
+  FileNameBufferLen,
+  L"%s%02d.%s",
+  BaseFileName,
+  Index,
+  Extension
+  );
+Status = ShellOpenFileByName (
+   FileName,
+   ,
+   EFI_FILE_MODE_READ,
+   0
+   );
+if (Status == EFI_NOT_FOUND) {
+  return EFI_SUCCESS;
+}
+ShellCloseFile ();
+  }
+  return EFI_OUT_OF_RESOURCES;
+}
 
 /**
   This function dumps the ACPI table to a file.
@@ -46,19 +93,27 @@ DumpAcpiTableToFile (
   IN CONST UINTN   Length
   )
 {
-  CHAR16  FileNameBuffer[MAX_FILE_NAME_LEN];
-  UINTN   TransferBytes;
-  SELECTED_ACPI_TABLE *SelectedTable;
+  CHAR16   FileNameBuffer[MAX_FILE_NAME_LEN];
+  UINTNTransferBytes;
+  EFI_STATUS   Status;
+  SELECTED_ACPI_TABLE* SelectedTable;
 
   GetSelectedAcpiTable ();
 
-  UnicodeSPrint (
-FileNameBuffer,
-sizeof (FileNameBuffer),
-L".\\%s%04d.bin",
-SelectedTable->Name,
-mBinTableCount++
-);
+  Status = GetNewFileName (
+ SelectedTable->Name,
+ L"bin",
+ FileNameBuffer,
+ sizeof (FileNameBuffer)
+ );
+  if (EFI_ERROR (Status)) {
+Print (
+  L"Error: Could not open bin file for %s table:\n"
+  L"Could not get

[edk2-devel] [PATCH edk2-platforms v1 1/1] Platform/ARM: FVP: Fix variable usage in GetArmNameSpaceObject()

2021-07-01 Thread Joey Gouly
Building with Clang showed that `RootComplexCount` and
`DeviceIdMappingArrayCount` were unused. Use the
variables where they were intended to be used.

Signed-off-by: Joey Gouly 
---

The changes can be seen at 
https://github.com/jgouly/edk2-platforms/tree/1766_vexpress_count_v1

 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
index 
e99fbb654f5109321e32905af3763233dffdbc3e..776dec999eb1ef47910835987fa4dae1b69c52fd
 100644
--- 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
+++ 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -924,7 +924,7 @@ GetArmNameSpaceObject (
  CmObjectId,
  >RootComplexInfo,
  sizeof (PlatformRepo->RootComplexInfo),
- 1,
+ RootComplexCount,
  CmObject
  );
   break;
@@ -935,7 +935,7 @@ GetArmNameSpaceObject (
  CmObjectId,
  PlatformRepo->DeviceIdMapping,
  sizeof (PlatformRepo->DeviceIdMapping),
- ARRAY_SIZE (PlatformRepo->DeviceIdMapping),
+ DeviceIdMappingArrayCount,
  Token,
  GetDeviceIdMappingArray,
  CmObject
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#77421): https://edk2.groups.io/g/devel/message/77421
Mute This Topic: https://groups.io/mt/83914555/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] ArmPkg/ArmGic: Fix maximum number of interrupts in GICv3

2021-05-21 Thread Joey Gouly
>From: Joey Gouly 
> Sent: 09 March 2021 16:45
> Subject: [PATCH] ArmPkg/ArmGic: Fix maximum number of interrupts in GICv3 
 
Hi,

A little ping on this. Can someone take a look?

There was a similar patch here, that addressed the same issue 
https://edk2.groups.io/g/devel/topic/82327316#74401 so I think it would be good 
get this in.

Thanks,
Joey

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#75445): https://edk2.groups.io/g/devel/message/75445
Mute This Topic: https://groups.io/mt/81205553/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v1 0/5] Dot graph generator for PPTT

2021-05-07 Thread Joey Gouly
> From: Joey Gouly 
> Sent: 07 May 2021 11:37


> The changes can be seen at 
> https://github.com/jgouly/edk2/tree/1484_pptt_dot_graph_v1

The CI on github showed some coding style issues with this series. I will fix 
those locally but wait for more review comments before I send a v2.

Thanks,
Joey

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74813): https://edk2.groups.io/g/devel/message/74813
Mute This Topic: https://groups.io/mt/82651820/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 2/5] ShellPkg: add a helper function for getting a new file name

2021-05-07 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This new helper will not overwrite existing files, by appending a number
to the end of the filename.

Signed-off-by: Marc Moisson-Franckhauser 
Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h | 25 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 80 

 2 files changed, 91 insertions(+), 14 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
index 
d5b95f5ee707de18be1879b3cd235d6c5db11d9f..ae8a67b7681033d66d068341ae489ded67de8b44
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
@@ -1,12 +1,13 @@
 /** @file
   Header file for AcpiView
 
-  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #ifndef ACPIVIEW_H_
 #define ACPIVIEW_H_
+#include 
 
 /**
   A macro to define the max file name length
@@ -23,6 +24,28 @@
 **/
 #define RSDP_LENGTH_OFFSET   20
 
+/**
+  This function finds a filename not already used by adding a number in between
+  the BaseFileName and the extension.
+
+  Make sure the buffer FileName is big enough before calling the function. A
+  size of MAX_FILE_NAME_LEN is recommended.
+
+  @param [in]  BaseFileName  Start of the desired file name.
+  @param [in]  Extension Extension of the desired file name
+ (without '.').
+  @param [in, out] FileName  Preallocated buffer for the returned file
+ name.
+  @param [in]  FileNameBufferLen Size of FileName buffer..
+**/
+EFI_STATUS
+GetNewFileName (
+  IN CONST CHAR16* BaseFileName,
+  IN CONST CHAR16* Extension,
+  IN OUT   CHAR16* FileName,
+  IN   UINT32  FileNameBufferLen
+  );
+
 /**
   This function resets the ACPI table error counter to Zero.
 **/
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 
a4242ba9d99b05d07c829520c4011439445aadb0..db7b2e2a30525cc85a333b93f5eb97ec3a517b37
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -27,8 +27,55 @@
 #include "Arm/SbbrValidator.h"
 #endif
 
-STATIC UINT32 mTableCount;
-STATIC UINT32 mBinTableCount;
+STATIC UINT32  mTableCount;
+
+/**
+  This function finds a filename not already used by adding a number in between
+  The BaseFileName and the extension.
+
+  Make sure the buffer FileName is big enough before calling the function. A
+  size of MAX_FILE_NAME_LEN is recommended.
+
+  @param [in]  BaseFileName  Start of the desired file name.
+  @param [in]  Extension Extension of the desired file name
+ (without '.').
+  @param [in, out] FileName  Preallocated buffer for the returned file
+ name.
+  @param [in]  FileNameBufferLen Size of FileName buffer..
+**/
+EFI_STATUS
+GetNewFileName (
+  IN CONST CHAR16* BaseFileName,
+  IN CONST CHAR16* Extension,
+  IN OUT   CHAR16* FileName,
+  IN   UINT32  FileNameBufferLen
+  )
+{
+  UINT16Index;
+  EFI_STATUSStatus;
+  SHELL_FILE_HANDLE tmpFileHandle;
+  for (Index = 0; Index <= 99; Index++) {
+UnicodeSPrint(
+  FileName,
+  FileNameBufferLen,
+  L"%s%02d.%s",
+  BaseFileName,
+  Index,
+  Extension
+  );
+Status = ShellOpenFileByName (
+   FileName,
+   ,
+   EFI_FILE_MODE_READ,
+   0
+   );
+if (Status == EFI_NOT_FOUND) {
+  return EFI_SUCCESS;
+}
+ShellCloseFile ();
+  }
+  return EFI_OUT_OF_RESOURCES;
+}
 
 /**
   This function dumps the ACPI table to a file.
@@ -46,19 +93,27 @@ DumpAcpiTableToFile (
   IN CONST UINTN   Length
   )
 {
-  CHAR16  FileNameBuffer[MAX_FILE_NAME_LEN];
-  UINTN   TransferBytes;
-  SELECTED_ACPI_TABLE *SelectedTable;
+  CHAR16   FileNameBuffer[MAX_FILE_NAME_LEN];
+  UINTNTransferBytes;
+  EFI_STATUS   Status;
+  SELECTED_ACPI_TABLE* SelectedTable;
 
   GetSelectedAcpiTable ();
 
-  UnicodeSPrint (
-FileNameBuffer,
-sizeof (FileNameBuffer),
-L".\\%s%04d.bin",
-SelectedTable->Name,
-mBinTableCount++
-);
+  Status = GetNewFileName (
+ SelectedTable->Name,
+ L"bin",
+ FileNameBuffer,
+ sizeof (FileNameBuffer)
+ );
+  if (EFI_ERROR (Status)) {
+Print (
+  L"Error: Could not open bin fi

[edk2-devel] [PATCH v1 1/5] ShellPkg: Replace 'Trace' parameter with 'ParseFlags'

2021-05-07 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This is preparation for adding a second flag to the parsers.

Signed-off-by: Marc Moisson-Franckhauser 
Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h  | 77 
+++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h |  6 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c | 20 
++---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c| 28 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Bgrt/BgrtParser.c | 10 +--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dsdt/DsdtParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c | 10 +--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c | 27 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 47 
+++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 10 +--
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ssdt/SsdtParser.c |  8 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c | 10 +--
 20 files changed, 179 insertions(+), 146 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 
0b7726b9d5807ad2f5c5447408c4c5451718938b..b078c0b99335ba28f7589cac6b0a4190d9a6c3b5
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for ACPI parser
 
-  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -16,6 +16,16 @@
 /// that allows us to process the log options.
 #define RSDP_TABLE_INFO  SIGNATURE_32('R', 'S', 'D', 'P')
 
+/**
+  Flags for the parser.
+*/
+#define PARSE_FLAGS_TRACE   BIT0
+
+/**
+  Helper macros to test parser flags.
+*/
+#define IS_TRACE_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_TRACE) != 0)
+
 /**
   This function increments the ACPI table error counter.
 **/
@@ -489,7 +499,7 @@ ParseAcpiAest (
 
   This function also performs validation of the ACPI table fields.
 
-  @param [in] Trace  If TRUE, trace the ACPI fields.
+  @param [in] ParseFlags Flags describing what the parser needs to do.
   @param [in] PtrPointer to the start of the buffer.
   @param [in] AcpiTableLengthLength of the ACPI table.
   @param [in] AcpiTableRevision  Revision of the ACPI table.
@@ -497,7 +507,7 @@ ParseAcpiAest (
 VOID
 EFIAPI
 ParseAcpiBgrt (
-  IN BOOLEAN Trace,
+  IN UINT8   ParseFlags,
   IN UINT8*  Ptr,
   IN UINT32  AcpiTableLength,
   IN UINT8   AcpiTableRevision
@@ -510,7 +520,7 @@ ParseAcpiBgrt (
 
   This function also performs validation of the ACPI table fields.
 
-  @param [in] Trace  If TRUE, trace the ACPI fields.
+  @param [in] ParseFlags Flags describing what the parser needs to do.
   @param [in] PtrPointer to the start of the buffer.
   @param [in] AcpiTableLengthLength of the ACPI table.
   @param [in] AcpiTableRevision  Revision of the ACPI table.
@@ -518,7 +528,7 @@ ParseAcpiBgrt (
 VOID
 EFIAPI
 ParseAcpiDbg2 (
-  IN BOOLEAN Trace,
+  IN UINT8   ParseFlags,
   IN UINT8*  Ptr,
   IN UINT32  AcpiTableLength,
   IN UINT8   AcpiTableRevision
@@ -531,7 +541,7 @@ ParseAcpiDbg2 (
   For the DSDT table only the ACPI header fields are parsed and
   traced.
 
-  @param [in] Trace  If TRUE, trace the ACPI fields.
+  @param [in] ParseFlags Flags describing what the parser needs to do.
   @param [in] PtrPointer to the start of the buffer.
   @param [in] AcpiTableLengthLength of the ACPI table.
   @param [in] AcpiTableRevision  Revision of the ACPI table.
@@ -539,7 +549,7 @@ ParseAcpiDbg2 (
 VOID
 EFIAPI
 ParseAcpiDsdt (
-  IN BOOLEAN Trace,
+  IN UINT8   ParseFlags,
   IN UINT8*  Ptr,
   IN UINT32  AcpiTableLength,
   IN UINT8   AcpiTableRevision
@@ -552,7 +562,7 @@ ParseAcpiDsdt (
 
   This function also performs validation of the ACPI table fields.
 
-  @p

[edk2-devel] [PATCH v1 4/5] ShellPkg: add dot file generator functions

2021-05-07 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

These can be used to generate dot files, that can be used to visualise
graphs in tables, such as PPTT.

Signed-off-by: Marc Moisson-Franckhauser 
Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 
  4 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h  | 
 97 +++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c  | 
276 
 3 files changed, 376 insertions(+), 1 deletion(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index 
63fc5a1281a894841dac704484c3d4f9481edb46..ffe4979b3ac5d0120bcf678cf7823afac6674e4f
 100644
--- 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -1,7 +1,7 @@
 ##  @file
 # Provides Shell 'acpiview' command functions
 #
-# Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -27,6 +27,8 @@ [Sources.common]
   AcpiView.h
   AcpiViewConfig.c
   AcpiViewConfig.h
+  DotGenerator.c
+  DotGenerator.h
   Parsers/Aest/AestParser.c
   Parsers/Bgrt/BgrtParser.c
   Parsers/Dbg2/Dbg2Parser.c
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h
new file mode 100644
index 
..7a8e2fdc2d2024ae54fdce963d751ab53a8a5758
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h
@@ -0,0 +1,97 @@
+/** @file
+  Header file for Dot File Generation
+
+  Copyright (c) 2021, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef DOT_GENERATOR_H_
+#define DOT_GENERATOR_H_
+
+#include 
+
+#define DOT_COLOR_MASK0b111
+// Flags for color of arrow or node.
+#define DOT_COLOR_BLACK   0b000 // default
+#define DOT_COLOR_GRAY0b001
+#define DOT_COLOR_BLUE0b010
+#define DOT_COLOR_YELLOW  0b011
+#define DOT_COLOR_RED 0b100
+
+#define DOT_ARROW_TYPE_MASK   0b1000
+// Flags for style of arrow.
+#define DOT_ARROW_FULL0b // default
+#define DOT_ARROW_DOTTED  0b1000
+
+// Flag for reversing how the nodes will be ranked and displayed.
+#define DOT_ARROW_RANK_REVERSE0b1
+
+#define DOT_BOX_TYPE_MASK 0b110
+// Flag for shape of box
+#define DOT_BOX_SQUARE0b000 // default
+#define DOT_BOX_DIAMOND   0b010
+
+// Flag for adding the node's ID to the end of the label.
+#define DOT_BOX_ADD_ID_TO_LABEL   0b1000
+
+// Valid flags for DotAddNode.
+#define DOT_BOX_FLAGS_MASK(DOT_COLOR_MASK |\
+   DOT_BOX_TYPE_MASK |\
+   DOT_BOX_ADD_ID_TO_LABEL)
+// Valid flags for DotAddLink.
+#define DOT_ARROW_FLAGS_MASK  (DOT_COLOR_MASK |\
+   DOT_ARROW_TYPE_MASK |\
+   DOT_ARROW_RANK_REVERSE)
+
+
+/**
+  Opens a new dot file and writes a dot directional graph.
+
+  @param [in] FileNameNull terminated unicode string.
+**/
+SHELL_FILE_HANDLE
+DotOpenNewFile (
+  IN CHAR16* FileName
+  );
+
+/**
+  Writes a dot graph footer and closes the dot file.
+**/
+VOID
+DotCloseFile (
+  SHELL_FILE_HANDLE DotFile
+  );
+
+/**
+  Writes a line in the previously opened dot file describing a
+  new node.
+
+  @param [in] IdA unique identifier for the node.
+  @param [in] Flags Flags describing the node's characteristics.
+  @param [in] Label Label to be shown on the graph node.
+**/
+VOID
+DotAddNode (
+  SHELL_FILE_HANDLE DotFile,
+  IN UINT32 Id,
+  IN UINT16 Flags,
+  IN CONST CHAR16*  Label
+  );
+
+/**
+  Writes a line in the previously opened dot file describing a
+  new link between two nodes.
+
+  @param [in] IdSourceAn identifier for the source node of the link.
+  @param [in] IdTargetAn identifier for the target node of the link.
+  @param [in] Flags   Flags describing the node's characteristics.
+**/
+VOID
+DotAddLink (
+  SHELL_FILE_HANDLE DotFile,
+  IN UINT32 IdSource,
+  IN UINT32 IdTarget,
+  IN UINT16 Flags
+  );
+
+#endif // DOT_GENERATOR_H_
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c
new file mode 100644
index 
..8c644d96af30ca4b1160bc892fe391ae1ff5211b
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c
@@ -0,0 +1,276 @@
+/** @file
+  Dot File Generator
+
+  Copyright (c) 2021

[edk2-devel] [PATCH v1 3/5] ShellPkg: add a Graph option to the Parser Flags

2021-05-07 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This option informs the parser to generate a dot graph of a table.
This can be useful to understand or debug a table, such as the PPTT
table.

Signed-off-by: Marc Moisson-Franckhauser 
Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h| 
 2 ++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h| 
 3 ++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c  | 
 9 +++-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c   | 
24 +---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni | 
 9 ++--
 5 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 
b078c0b99335ba28f7589cac6b0a4190d9a6c3b5..9a67fe084327434bf21b37b3089779468edfb0f1
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -20,11 +20,13 @@
   Flags for the parser.
 */
 #define PARSE_FLAGS_TRACE   BIT0
+#define PARSE_FLAGS_GRAPH   BIT1
 
 /**
   Helper macros to test parser flags.
 */
 #define IS_TRACE_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_TRACE) != 0)
+#define IS_GRAPH_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_GRAPH) != 0)
 
 /**
   This function increments the ACPI table error counter.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
index 
2db4a65415d8f9e70686cb2cc432862ab4e4c2dd..262302a15cbbe04a228fd55e523930fb76bcf6a8
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for 'acpiview' configuration.
 
-  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -106,6 +106,7 @@ typedef enum {
   ReportSelected, ///< Report Selected table.
   ReportTableList,///< Report List of tables.
   ReportDumpBinFile,  ///< Dump selected table to a file.
+  ReportDotGraph, ///< Create Dot Graph for selected compatible table.
   ReportMax,
 } EREPORT_OPTION;
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 
db7b2e2a30525cc85a333b93f5eb97ec3a517b37..1155b2f3f411247c866f635fb666dd76455f18a4
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -192,6 +192,12 @@ ProcessTableReportOptions (
 DumpAcpiTableToFile (TablePtr, Length);
   }
   break;
+case ReportDotGraph:
+  if (Signature == SelectedTable->Type) {
+SelectedTable->Found = TRUE;
+ParseFlags |= PARSE_FLAGS_GRAPH;
+  }
+  break;
 case ReportMax:
   // We should never be here.
   // This case is only present to prevent compiler warning.
@@ -340,7 +346,8 @@ AcpiView (
 
   ReportOption = GetReportOption ();
   if (ReportTableList != ReportOption) {
-if (((ReportSelected == ReportOption)  ||
+if (((ReportSelected == ReportOption) ||
+ (ReportDotGraph == ReportOption) ||
  (ReportDumpBinFile == ReportOption)) &&
 (!SelectedTable->Found)) {
   Print (L"\nRequested ACPI Table not found.\n");
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index 
b30ed3fc8597b229dd15b6ad4f2aab2e3d0ca583..d837b390938f3c3bc5cb90c1161e2feeb1ed6a6b
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -1,7 +1,7 @@
 /** @file
   Main file for 'acpiview' Shell command function.
 
-  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -34,6 +34,7 @@ EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-q", TypeFlag},
   {L"-d", TypeFlag},
+  {L"-g", TypeFlag},
   {L"-h", TypeFlag},
   {L"-l", TypeFlag},
   {L"-s", TypeValue},
@@ -293,6 +294,18 @@ ShellCommandRunAcpiView (
   L"-d"
   );
 ShellStatus = SHELL_INVALID_PARAMETER;
+} else if (ShellCommandLineGetFlag (Package, L"-g") &&
+   !ShellCommandLineGetFlag (Packa

[edk2-devel] [PATCH v1 0/5] Dot graph generator for PPTT

2021-05-07 Thread Joey Gouly
This series adds functionality to print a dot graph of a PPTT table.
This helps with understanding and debugging PPTT tables.
The dot graph generator functionality is generic and could be used by
other tables that would benefit from graph output.

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

The changes can be seen at 
https://github.com/jgouly/edk2/tree/1484_pptt_dot_graph_v1

Marc Moisson-Franckhauser (5):
  ShellPkg: Replace 'Trace' parameter with 'ParseFlags'
  ShellPkg: add a helper function for getting a new file name
  ShellPkg: add a Graph option to the Parser Flags
  ShellPkg: add dot file generator functions
  ShellPkg: add PPTT dot file genration

 .../UefiShellAcpiViewCommandLib.inf   |   4 +-
 .../UefiShellAcpiViewCommandLib/AcpiParser.h  |  79 +++--
 .../AcpiTableParser.h |   6 +-
 .../UefiShellAcpiViewCommandLib/AcpiView.h|  25 +-
 .../AcpiViewConfig.h  |   3 +-
 .../DotGenerator.h|  97 ++
 .../AcpiTableParser.c |  20 +-
 .../UefiShellAcpiViewCommandLib/AcpiView.c| 117 +--
 .../DotGenerator.c| 276 +
 .../Parsers/Bgrt/BgrtParser.c |  10 +-
 .../Parsers/Dbg2/Dbg2Parser.c |   8 +-
 .../Parsers/Dsdt/DsdtParser.c |   8 +-
 .../Parsers/Facs/FacsParser.c |  10 +-
 .../Parsers/Fadt/FadtParser.c |  27 +-
 .../Parsers/Gtdt/GtdtParser.c |   8 +-
 .../Parsers/Iort/IortParser.c |   8 +-
 .../Parsers/Madt/MadtParser.c |   8 +-
 .../Parsers/Mcfg/McfgParser.c |   8 +-
 .../Parsers/Pptt/PpttParser.c | 285 +++---
 .../Parsers/Rsdp/RsdpParser.c |  10 +-
 .../Parsers/Slit/SlitParser.c |   8 +-
 .../Parsers/Spcr/SpcrParser.c |   8 +-
 .../Parsers/Srat/SratParser.c |   8 +-
 .../Parsers/Ssdt/SsdtParser.c |   8 +-
 .../Parsers/Xsdt/XsdtParser.c |  10 +-
 .../UefiShellAcpiViewCommandLib.c |  24 +-
 .../UefiShellAcpiViewCommandLib.uni   |   9 +-
 27 files changed, 903 insertions(+), 189 deletions(-)
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h
 create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c

-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74808): https://edk2.groups.io/g/devel/message/74808
Mute This Topic: https://groups.io/mt/82651820/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 5/5] ShellPkg: add PPTT dot file genration

2021-05-07 Thread Joey Gouly
From: Marc Moisson-Franckhauser 

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This generates a dot file from the PPTT table that can be used to
visualise the topology of the CPUs and Caches.

Signed-off-by: Marc Moisson-Franckhauser 
Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 240 
++--
 1 file changed, 218 insertions(+), 22 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
index 
538b6a69350d75ccbf36b86fff115255e77437c7..b52bd532b846b9cec0ca315b043beff95df40bd5
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
@@ -15,11 +15,23 @@
 #include "AcpiView.h"
 #include "AcpiViewConfig.h"
 #include "PpttParser.h"
+#include "DotGenerator.h"
 
 // Local variables
 STATIC CONST UINT8*  ProcessorTopologyStructureType;
 STATIC CONST UINT8*  ProcessorTopologyStructureLength;
+
 STATIC CONST UINT32* NumberOfPrivateResources;
+STATIC CONST UINT32* ProcessorHierarchyParent;
+STATIC CONST EFI_ACPI_6_3_PPTT_STRUCTURE_PROCESSOR_FLAGS* ProcStructFlags;
+STATIC CONST UINT32* NextLevelOfCache;
+STATIC CONST EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE_ATTRIBUTES* CacheAttributes;
+STATIC CONST UINT32* CacheSize;
+
+STATIC CONST UINT8*  PpttStartPointer;
+
+STATIC SHELL_FILE_HANDLE mDotFileHandle;
+
 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
 
 /**
@@ -198,8 +210,9 @@ STATIC CONST ACPI_PARSER 
ProcessorHierarchyNodeStructureParser[] = {
   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
 
-  {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
-  {L"Parent", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
+  {L"Flags", 4, 4, L"0x%x", NULL, (VOID**), NULL, NULL},
+  {L"Parent", 4, 8, L"0x%x", NULL,
+(VOID**), NULL, NULL},
   {L"ACPI Processor ID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
   {L"Number of private resources", 4, 16, L"%d", NULL,
(VOID**), NULL, NULL}
@@ -214,11 +227,13 @@ STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = {
   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
 
   {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
-  {L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
-  {L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
+  {L"Next Level of Cache", 4, 8, L"0x%x", NULL,
+(VOID**), NULL, NULL},
+  {L"Size", 4, 12, L"0x%x", NULL, (VOID**), NULL, NULL},
   {L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, 
NULL},
   {L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, 
NULL},
-  {L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL},
+  {L"Attributes", 1, 21, L"0x%x", NULL, (VOID**),
+ValidateCacheAttributes, NULL},
   {L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL}
 };
 
@@ -257,6 +272,7 @@ DumpProcessorHierarchyNodeStructure (
   UINT32 Offset;
   UINT32 Index;
   CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
+  CONST UINT8* TypePtr;
 
   Offset = ParseAcpi (
  IS_TRACE_FLAG_SET (ParseFlags),
@@ -291,26 +307,67 @@ DumpProcessorHierarchyNodeStructure (
 return;
   }
 
-  Index = 0;
+  if (IS_GRAPH_FLAG_SET (ParseFlags)) {
+if (ProcStructFlags->ProcessorIsAThread) {
+  UnicodeSPrint(Buffer, sizeof (Buffer), L"Thread");
+} else if (ProcStructFlags->NodeIsALeaf) {
+  UnicodeSPrint(Buffer, sizeof (Buffer), L"Core");
+} else if (ProcStructFlags->PhysicalPackage) {
+  UnicodeSPrint(Buffer, sizeof (Buffer), L"Physical\\nPackage");
+} else {
+  UnicodeSPrint(Buffer, sizeof (Buffer), L"Cluster");
+}
+
+DotAddNode (
+  mDotFileHandle,
+  (UINT32)(Ptr - PpttStartPointer),
+  DOT_BOX_SQUARE | DOT_COLOR_BLUE | DOT_BOX_ADD_ID_TO_LABEL,
+  Buffer
+  );
+
+// Add link to parent node.
+if (*ProcessorHierarchyParent != 0) {
+  DotAddLink (
+mDotFileHandle,
+(UINT32)(Ptr - PpttStartPointer),
+*ProcessorHierarchyParent,
+0x0
+);
+}
+  }
 
   // Parse the specified number of private resource references or the Processor
   // Hierarchy Node length. Whichever is minimum.
-  while (Index < *NumberOfPrivateResources) {
-UnicodeSPrint (
-  Buffer,
-  sizeof (Buffer),
-  L"Private resources [%d

[edk2-devel] [PATCH v1 1/4] ShellPkg: Rename Address Size to Access size

2021-04-15 Thread Joey Gouly
This matches the ACPI spec 6.3, table 5.1: Generic Address Structure.

Signed-off-by: Joey Gouly 
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
index 
01ac9a9bafeb2ca12c1ba19f406d626b108f5fe2..74056e72c359c732758563a9fe14ff2582f39f21
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
@@ -1,7 +1,7 @@
 /** @file
   ACPI parser
 
-  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -628,7 +628,7 @@ STATIC CONST ACPI_PARSER GasParser[] = {
   {L"Address Space ID", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
   {L"Register Bit Width", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},
   {L"Register Bit Offset", 1, 2, L"0x%x", NULL, NULL, NULL, NULL},
-  {L"Address Size", 1, 3, L"0x%x", NULL, NULL, NULL, NULL},
+  {L"Access Size", 1, 3, L"0x%x", NULL, NULL, NULL, NULL},
   {L"Address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL}
 };
 
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74130): https://edk2.groups.io/g/devel/message/74130
Mute This Topic: https://groups.io/mt/82115122/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 3/4] DynamicTablesPkg: Set the Access size for the SPCR table

2021-04-15 Thread Joey Gouly
The SPCR table generator set the access size for the UART to
DWORD (4 bytes) by default. However, according to Section B
Generic UART, Arm Base System Architecture 1.0, Platform
Design Document, a Generic UART can have BYTE, WORD or DWORD
access sizes. To address this an AccessSize field has been
introduced in CM_ARM_SERIAL_PORT_INFO object.

This patch updates the SPCR generator to setup the AccessSize
field in the Generic Address Structure (GAS) for the UART in
the SPCR table with information provided by the platform.

Signed-off-by: Joey Gouly 
---
 DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c | 22 
+++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
index 
24bb5c014607b0746c4a8bb8bd260510fbdff08b..fecfd6bbabd63698f5f45f6bfbd494f25cf0faeb
 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
@@ -1,7 +1,7 @@
 /** @file
   SPCR Table Generator
 
-  Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -313,6 +313,26 @@ BuildSpcrTableEx (
   // Update the base address
   AcpiSpcr.BaseAddress.Address = SerialPortInfo->BaseAddress;
 
+  // Set the access size
+  if (SerialPortInfo->AccessSize >= EFI_ACPI_6_3_QWORD) {
+Status = EFI_INVALID_PARAMETER;
+DEBUG ((
+  DEBUG_ERROR,
+  "ERROR: SPCR: Access size must be <= 3 (DWORD). Status = %r\n",
+  Status
+  ));
+goto error_handler;
+  } else if (SerialPortInfo->AccessSize == EFI_ACPI_6_3_UNDEFINED) {
+// 0 Undefined (legacy reasons)
+// Default to DWORD access size as the access
+// size field was introduced at a later date
+// and some ConfigurationManager implementations
+// may not be providing this field data
+AcpiSpcr.BaseAddress.AccessSize = EFI_ACPI_6_3_DWORD;
+  } else {
+AcpiSpcr.BaseAddress.AccessSize = SerialPortInfo->AccessSize;
+  }
+
   // Update the UART interrupt
   AcpiSpcr.GlobalSystemInterrupt = SerialPortInfo->Interrupt;
 
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74128): https://edk2.groups.io/g/devel/message/74128
Mute This Topic: https://groups.io/mt/82115120/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 0/4] DynamicTablesPkg: Add access size parameter for serial ports

2021-04-15 Thread Joey Gouly
This series adds the Access Size parameter to the Serial Port in
DynamicTablesPkg.

This has been tested (by Sami) with kvmtool, which virtualises a UART
with 8 bit access size.

Changes available at 
https://github.com/jgouly/edk2/tree/1586_serial_port_access_size_v1

Joey Gouly (4):
  ShellPkg: Rename Address Size to Access size
  DynamicTablesPkg: Add access size to CM_ARM_SERIAL_PORT_INFO
  DynamicTablesPkg: Set the Access size for the SPCR table
  DynamicTablesPkg: Set the Access size for the DBG2 table

 .../Include/ArmNameSpaceObjects.h |  3 +++
 .../Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c   | 24 ++-
 .../Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c   | 22 -
 .../UefiShellAcpiViewCommandLib/AcpiParser.c  |  4 ++--
 4 files changed, 49 insertions(+), 4 deletions(-)

-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74129): https://edk2.groups.io/g/devel/message/74129
Mute This Topic: https://groups.io/mt/82115121/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 2/4] DynamicTablesPkg: Add access size to CM_ARM_SERIAL_PORT_INFO

2021-04-15 Thread Joey Gouly
Add access size to CM_ARM_SERIAL_PORT_INFO so that this can be
passed down to the Generic Address Structure.

Signed-off-by: Joey Gouly 
---
 DynamicTablesPkg/Include/ArmNameSpaceObjects.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
index 
afcfe3704cb908afb1e6b17e6771b2ebe3f67f76..19dcae13b2191e5f0b03ea85edec1191d2a406bf
 100644
--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
@@ -293,6 +293,9 @@ typedef struct CmArmSerialPortInfo {
 
   /// The Base address length
   UINT64  BaseAddressLength;
+
+  /// The access size
+  UINT8   AccessSize;
 } CM_ARM_SERIAL_PORT_INFO;
 
 /** A structure that describes the
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74127): https://edk2.groups.io/g/devel/message/74127
Mute This Topic: https://groups.io/mt/82115118/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 4/4] DynamicTablesPkg: Set the Access size for the DBG2 table

2021-04-15 Thread Joey Gouly
The DBG2 table generator set the access size for the UART to
DWORD (4 bytes) by default. However, according to Section B
Generic UART, Arm Base System Architecture 1.0, Platform
Design Document, a Generic UART can have BYTE, WORD or DWORD
access sizes. To address this an AccessSize field has been
introduced in CM_ARM_SERIAL_PORT_INFO object.

This patch updates the DBG2 generator to setup the AccessSize
field in the Generic Address Structure (GAS) for the UART in
the DBG2 table with information provided by the platform.

Signed-off-by: Joey Gouly 
---
 DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c | 24 
+++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
index 
d902bbc8463921624f1a6333e8d6bd84c6cb38f2..a7508d4a8834fd2038946a62de39e9cd0894bf79
 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
@@ -1,7 +1,7 @@
 /** @file
   DBG2 Table Generator
 
-  Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -420,6 +420,28 @@ BuildDbg2TableEx (
   AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].BaseAddressRegister.Address =
 SerialPortInfo->BaseAddress;
 
+  // Set the access size
+  if (SerialPortInfo->AccessSize >= EFI_ACPI_6_3_QWORD) {
+Status = EFI_INVALID_PARAMETER;
+DEBUG ((
+  DEBUG_ERROR,
+  "ERROR: DBG2: Access size must be <= 3 (DWORD). Status = %r\n",
+  Status
+  ));
+goto error_handler;
+  } else if (SerialPortInfo->AccessSize == EFI_ACPI_6_3_UNDEFINED) {
+// 0 Undefined (legacy reasons)
+// Default to DWORD access size as the access
+// size field was introduced at a later date
+// and some ConfigurationManager implementations
+// may not be providing this field data
+AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].BaseAddressRegister.AccessSize =
+  EFI_ACPI_6_3_DWORD;
+  } else {
+AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].BaseAddressRegister.AccessSize =
+  SerialPortInfo->AccessSize;
+  }
+
   // Update the serial port subtype
   AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].Dbg2Device.PortSubtype =
 SerialPortInfo->PortSubtype;
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74126): https://edk2.groups.io/g/devel/message/74126
Mute This Topic: https://groups.io/mt/82115095/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] DynamicTablesPkg: add validation for PcdNonBsaCompliant16550SerialHid

2021-04-13 Thread Joey Gouly
> Hi Joey,
> 
> Can you confirm that your sign-off ID is correct, please?
> Otherwise this patch looks good to me.

That was silly to typo my own name!

Signed-off-by: Joey Gouly 

Thanks for the review!
Joey

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#74022): https://edk2.groups.io/g/devel/message/74022
Mute This Topic: https://groups.io/mt/81966375/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] DynamicTablesPkg: add validation for PcdNonBsaCompliant16550SerialHid

2021-04-09 Thread Joey Gouly
According to ACPI 6.4, 6.1.5 _HID states:

  - A valid PNP ID must be of the form "AAA" where A is an uppercase
letter and # is a hex digit.
  - A valid ACPI ID must be of the form "" where N is an uppercase
letter or a digit ('0'-'9') and # is a hex digit.

Signed-off-by: Joey Gouly 
---

The changes can be seen at 
https://github.com/jgouly/edk2/tree/1645_non_sba_compliant_validation_v1

 DynamicTablesPkg/Include/Library/TableHelperLib.h  
 | 38 +-
 
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c 
|  4 ++
 DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c   
 | 73 +++-
 3 files changed, 113 insertions(+), 2 deletions(-)

diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h 
b/DynamicTablesPkg/Include/Library/TableHelperLib.h
index 
099a0a4544e3d1f746d4be8533cb006786f11611..0f93cdbf08953af2377952ef616f760a51706170
 100644
--- a/DynamicTablesPkg/Include/Library/TableHelperLib.h
+++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -12,6 +12,18 @@
 #ifndef TABLE_HELPER_LIB_H_
 #define TABLE_HELPER_LIB_H_
 
+/** Is a character upper case
+*/
+#define IS_UPPER_CHAR(x) ((x >= 'A') && (x <= 'Z'))
+
+/** Is a character a decimal digit
+*/
+#define IS_DIGIT(x) ((x >= '0') && (x <= '9'))
+
+/** Is a character an upper case hexadecimal digit
+*/
+#define IS_UPPER_HEX(x) (((x >= 'A') && (x <= 'F')) || IS_DIGIT (x))
+
 /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
 object from the Configuration Manager.
 
@@ -120,4 +132,28 @@ AsciiFromHex (
   IN  UINT8   x
   );
 
+/** Check if a HID is a valid PNP ID.
+
+  @param [in] Hid The Hid to validate.
+
+  @retvalTRUE The Hid is a valid PNP ID.
+  @retvalFALSEThe Hid is not a valid PNP ID.
+**/
+BOOLEAN
+IsValidPnpId (
+  IN  CONST CHAR8  * Hid
+  );
+
+/** Check if a HID is a valid ACPI ID.
+
+  @param [in] Hid The Hid to validate.
+
+  @retvalTRUE The Hid is a valid ACPI ID.
+  @retvalFALSEThe Hid is not a valid ACPI ID.
+**/
+BOOLEAN
+IsValidAcpiId (
+  IN  CONST CHAR8  * Hid
+  );
+
 #endif // TABLE_HELPER_LIB_H_
diff --git 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
index 
3c4356097c3bf25e8d1432b45ba8ca59d33e8d09..f2b4831ad596284476fb342148d9c1f62bc7f98b
 100644
--- 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
+++ 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
@@ -148,6 +148,10 @@ FixupIds (
   // If there is a non-BSA compliant HID, use that.
   NonBsaHid = (CONST CHAR8*)PcdGetPtr (PcdNonBsaCompliant16550SerialHid);
   if ((NonBsaHid != NULL) && (AsciiStrLen (NonBsaHid) != 0)) {
+if (!(IsValidPnpId (NonBsaHid) || IsValidAcpiId (NonBsaHid))) {
+  return EFI_INVALID_PARAMETER;
+}
+
 HidString = NonBsaHid;
 CidString = "";
   } else {
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c 
b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
index 
0d9daad3b05b6e82089f92afb6de45af9a28..9830ce62b3cb94be6d861a09d8d8356d60fdfbba
 100644
--- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
@@ -1,7 +1,7 @@
 /** @file
   Table Helper
 
-  Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -270,3 +270,74 @@ AsciiFromHex (
   ASSERT (FALSE);
   return (UINT8)0;
 }
+
+/** Check if a HID is a valid PNP ID.
+
+  @param [in] Hid The Hid to validate.
+
+  @retvalTRUE The Hid is a valid PNP ID.
+  @retvalFALSEThe Hid is not a valid PNP ID.
+**/
+BOOLEAN
+IsValidPnpId (
+  IN  CONST CHAR8  * Hid
+  )
+{
+  UINTN Index;
+
+  if (AsciiStrLen (Hid) != 7) {
+return FALSE;
+  }
+
+  // A valid PNP ID must be of the form "AAA"
+  // where A is an uppercase letter and # is a hex digit.
+  for (Index = 0; Index < 3; Index++) {
+if (!IS_UPPER_CHAR (Hid[Index])) {
+  return FALSE;
+}
+  }
+
+  for (Index = 3; Index < 7; Index++) {
+if (!IS_UPPER_HEX (Hid[Index])) {
+  return FALSE;
+}
+  }
+
+  return TRUE;
+}
+
+/** Check if a HID is a valid ACPI ID.
+
+  @param [in] Hid The Hid to validate.
+
+  @retvalTRUE The Hid is a valid ACPI ID.
+  @retvalFALSEThe Hid is not 

Re: [edk2-devel] [PATCH v2 1/1] ShellPkg: Validate that the Boot CPU is present in MADT

2021-03-10 Thread Joey Gouly
> From: devel@edk2.groups.io  on behalf of Ni, Ray via 
> groups.io 
> Is this for ARM only?

Yes, the GIC interrupt controller is for Arm only.

Thanks,
Joey
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#72631): https://edk2.groups.io/g/devel/message/72631
Mute This Topic: https://groups.io/mt/79702862/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] ArmPkg/ArmGic: Fix maximum number of interrupts in GICv3

2021-03-09 Thread Joey Gouly
From: Andreas Sandberg 

The GICv3 architecture supports up to 1020 ordinary interrupt
lines. The actual number of interrupts supported is described by the
ITLinesNumber field in the GICD_TYPER register. The total number of
implemented registers is normally calculated as
32*(ITLinesNumber+1). However, maximum value (0x1f) is a special case
since that would indicate that 1024 interrupts are implemented.

Add handling for this special case in ArmGicGetMaxNumInterrupts.

Signed-off-by: Andreas Sandberg 
Signed-off-by: Joey Gouly 
---

The changes can be seen at 
https://github.com/jgouly/edk2/tree/1396_gic_max_num_intr_v1

 ArmPkg/Drivers/ArmGic/ArmGicLib.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c 
b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
index 
6b01c88206ad8adef3100dd44c0d57660db77783..c4996970eb299776552fe7b54f34fd5a68afff29
 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c
+++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c
@@ -1,6 +1,6 @@
 /** @file
 *
-*  Copyright (c) 2011-2018, ARM Limited. All rights reserved.
+*  Copyright (c) 2011-2021, ARM Limited. All rights reserved.
 *
 *  SPDX-License-Identifier: BSD-2-Clause-Patent
 *
@@ -120,7 +120,12 @@ ArmGicGetMaxNumInterrupts (
   IN  INTN  GicDistributorBase
   )
 {
-  return 32 * ((MmioRead32 (GicDistributorBase + ARM_GIC_ICDICTR) & 0x1F) + 1);
+  UINTN ItLines;
+
+  ItLines = MmioRead32 (GicDistributorBase + ARM_GIC_ICDICTR) & 0x1F;
+
+  // Interrupt ID 1020-1023 are reserved;
+  return (ItLines == 0x1f) ? 1020 : 32 * (ItLines + 1);
 }
 
 VOID
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#72596): https://edk2.groups.io/g/devel/message/72596
Mute This Topic: https://groups.io/mt/81205553/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2 1/1] ShellPkg: Validate that the Boot CPU is present in MADT

2021-03-09 Thread Joey Gouly
> From: Joey Gouly 
> Subject: [PATCH v2 1/1] ShellPkg: Validate that the Boot CPU is present in 
> MADT
>
> The ACPI 6.3 Specification, January 2019, section 5.2.12.14 states that
> the firmware must convey each processor’s GIC information to the OS using
> the GICC structure.
>
> If a GICC structure for the boot CPU is missing some standards-based
> operating system may crash with an error code. It may be difficult to
> diagnose the reason for the crash as the error code may be too generic
> and mean firmware error.
>
> Therefore add validation to the MADT table parser to check that a GICC is
> present for the boot CPU.

Ping.

Is anyone able to review this patch adding some more validation checks to 
Acpiview / MADT?

Thanks,
Joey

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#72594): https://edk2.groups.io/g/devel/message/72594
Mute This Topic: https://groups.io/mt/79702862/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 2/2] DynamicTablesPkg: Add an override for 16550 HID in SSDT

2021-01-22 Thread Joey Gouly
Some platforms advertise support for a 16550 UART, but are not
compatible with the PNP0500 HID. Allow them to override the HID by
setting PcdNonBsaCompliant16550SerialHid.

Signed-off-by: Joey Gouly 
---
 DynamicTablesPkg/DynamicTablesPkg.dec  
   |  3 +++
 
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
 |  4 +++-
 
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c 
  | 14 +++---
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
index 
291a45a69679ae82219ecd2f26dfabfbab1f7f65..b242df01058729ce74d40c1fcf931acc3bc66fa5
 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -44,5 +44,8 @@ [PcdsFixedAtBuild]
   # Maximum number of Custom DT Generators
   
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomDTGenerators|1|UINT16|0xC003
 
+  # Non BSA Compliant 16550 Serial HID
+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdNonBsaCompliant16550SerialHid|""|VOID*|0x4008
+
 [Guids]
   gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8, 0x4613, { 0x87, 
0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } }
diff --git 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
index 
af3d404393f5f1385ab2d40f45f7222ab66f9b3a..54bf71a3b73949a9c834445a81bdade02d49e9d3
 100644
--- 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
+++ 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  SSDT Serial Port fixup Library
 #
-#  Copyright (c) 2020, Arm Limited. All rights reserved.
+#  Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
@@ -28,3 +28,5 @@ [LibraryClasses]
   AmlLib
   BaseLib
 
+[Pcd]
+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdNonBsaCompliant16550SerialHid
diff --git 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
index 
0ff071485ef25f4ca63de0eeab5120d1beece4db..3c4356097c3bf25e8d1432b45ba8ca59d33e8d09
 100644
--- 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
+++ 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
@@ -1,7 +1,7 @@
 /** @file
   SSDT Serial Port Fixup Library.
 
-  Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -139,13 +139,21 @@ FixupIds (
   AML_OBJECT_NODE_HANDLENameOpIdNode;
   CONST CHAR8 * HidString;
   CONST CHAR8 * CidString;
+  CONST CHAR8 * NonBsaHid;
 
   // Get the _CID and _HID value to write.
   switch (SerialPortInfo->PortSubtype) {
 case EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_FULL_16550:
 {
-  HidString = "PNP0501";
-  CidString = "PNP0500";
+  // If there is a non-BSA compliant HID, use that.
+  NonBsaHid = (CONST CHAR8*)PcdGetPtr (PcdNonBsaCompliant16550SerialHid);
+  if ((NonBsaHid != NULL) && (AsciiStrLen (NonBsaHid) != 0)) {
+HidString = NonBsaHid;
+CidString = "";
+  } else {
+HidString = "PNP0501";
+CidString = "PNP0500";
+  }
   break;
 }
 case EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART:
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70679): https://edk2.groups.io/g/devel/message/70679
Mute This Topic: https://groups.io/mt/80029091/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 0/2] Add a Pcd to override the 16650 HID in SSDT

2021-01-22 Thread Joey Gouly
This series adds PcdNonSbsaCompliantSerialHid so that firmware can
override the PNP0501 HID used by 16550 UART in the SSDT table, in case
they are not compatible with the generic PNP0501 HID.

I have tested this with acpiview, some extra testing would be
appreciated.

Changes available at https://github.com/jgouly/edk2/tree/1588_non_sbsa_hid_v2

v2:
  - Renamed PcdNonSbsaCompliantSerialHid to PcdNonBsaCompliant16550SerialHid

Joey Gouly (2):
  DynamicTablesPkg: Don't use gEfiMdeModulePkgTokenSpaceGuid
  DynamicTablesPkg: Add an override for 16550 HID in SSDT

 DynamicTablesPkg/DynamicTablesPkg.dec  | 13 +
 .../DynamicTableFactoryDxe.inf |  8 
 .../SsdtSerialPortFixupLib.inf |  4 +++-
 .../SsdtSerialPortFixupLib.c   | 14 +++---
 4 files changed, 27 insertions(+), 12 deletions(-)

-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70678): https://edk2.groups.io/g/devel/message/70678
Mute This Topic: https://groups.io/mt/80029085/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 1/2] DynamicTablesPkg: Don't use gEfiMdeModulePkgTokenSpaceGuid

2021-01-22 Thread Joey Gouly
Introduce gEdkiiDynamicTablesPkgTokenSpaceGuid and use that instead.

Signed-off-by: Joey Gouly 
Reviewed-by: Liming Gao 
---
 DynamicTablesPkg/DynamicTablesPkg.dec  | 
10 ++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf |  
8 
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
index 
f36a6e8bb7c17f82acff3c766b15202b064a64b5..291a45a69679ae82219ecd2f26dfabfbab1f7f65
 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -1,7 +1,7 @@
 ## @file
 # dec file for Dynamic Tables Framework.
 #
-# Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -36,11 +36,13 @@ [Protocols]
 [PcdsFixedAtBuild]
 
   # Maximum number of Custom ACPI Generators
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomACPIGenerators|1|UINT16|0xC001
+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomACPIGenerators|1|UINT16|0xC001
 
   # Maximum number of Custom SMBIOS Generators
-  
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomSMBIOSGenerators|1|UINT16|0xC002
+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomSMBIOSGenerators|1|UINT16|0xC002
 
   # Maximum number of Custom DT Generators
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomDTGenerators|1|UINT16|0xC003
+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomDTGenerators|1|UINT16|0xC003
 
+[Guids]
+  gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8, 0x4613, { 0x87, 
0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } }
diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf 
b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf
index 
56b69591ac52ca3ba51250dc01a0846b22442ce9..29ed3dc2e5029206f8852c4b11240e7b493bbc57
 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf
+++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Module to manage the list of available table factories.
 #
-#  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+#  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
@@ -41,9 +41,9 @@ [LibraryClasses]
   UefiDriverEntryPoint
 
 [FixedPcd]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomACPIGenerators
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomSMBIOSGenerators
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomDTGenerators
+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomACPIGenerators
+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomSMBIOSGenerators
+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomDTGenerators
 
 [Protocols]
   gEdkiiDynamicTableFactoryProtocolGuid # PRODUCES
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70677): https://edk2.groups.io/g/devel/message/70677
Mute This Topic: https://groups.io/mt/80029084/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 0/2] Add a Pcd to override the 16650 HID in SSDT

2021-01-20 Thread Joey Gouly
This series adds PcdNonSbsaCompliantSerialHid so that firmware can
override the PNP0501 HID used by 16550 UART in the SSDT table, in case
they are not compatible with the generic PNP0501 HID.

I have tested this with acpiview, some extra testing would be
appreciated.

Changes available at https://github.com/jgouly/edk2/tree/1588_non_sbsa_hid_v1

Joey Gouly (2):
  DynamicTablesPkg: Don't use gEfiMdeModulePkgTokenSpaceGuid
  DynamicTablesPkg: Add an override for 16550 HID in SSDT

 DynamicTablesPkg/DynamicTablesPkg.dec  | 13 +
 .../DynamicTableFactoryDxe.inf |  8 
 .../SsdtSerialPortFixupLib.inf |  4 +++-
 .../SsdtSerialPortFixupLib.c   | 14 +++---
 4 files changed, 27 insertions(+), 12 deletions(-)

-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70591): https://edk2.groups.io/g/devel/message/70591
Mute This Topic: https://groups.io/mt/79984776/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 2/2] DynamicTablesPkg: Add an override for 16550 HID in SSDT

2021-01-20 Thread Joey Gouly
Some platforms advertise support for a 16550 UART, but are not
compatible with the PNP0500 HID. Allow them to override the HID by
setting PcdNonSbsaCompliantSerialHid.

Signed-off-by: Joey Gouly 
---
 DynamicTablesPkg/DynamicTablesPkg.dec  
   |  3 +++
 
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
 |  4 +++-
 
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c 
  | 14 +++---
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
index 
291a45a69679ae82219ecd2f26dfabfbab1f7f65..3ec4fff116a8f538be331edf341867948c025116
 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -44,5 +44,8 @@ [PcdsFixedAtBuild]
   # Maximum number of Custom DT Generators
   
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomDTGenerators|1|UINT16|0xC003
 
+  # Non SBSA Compliant Serial HID
+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdNonSbsaCompliantSerialHid|""|VOID*|0x4008
+
 [Guids]
   gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8, 0x4613, { 0x87, 
0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } }
diff --git 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
index 
af3d404393f5f1385ab2d40f45f7222ab66f9b3a..b64825982e8fb7aaf78f3fd68992e1c78d20c408
 100644
--- 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
+++ 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  SSDT Serial Port fixup Library
 #
-#  Copyright (c) 2020, Arm Limited. All rights reserved.
+#  Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
@@ -28,3 +28,5 @@ [LibraryClasses]
   AmlLib
   BaseLib
 
+[Pcd]
+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdNonSbsaCompliantSerialHid
diff --git 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
index 
0ff071485ef25f4ca63de0eeab5120d1beece4db..73a8087ed8a8ff84b64531a3c73d319585dfb6cf
 100644
--- 
a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
+++ 
b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
@@ -1,7 +1,7 @@
 /** @file
   SSDT Serial Port Fixup Library.
 
-  Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -139,13 +139,21 @@ FixupIds (
   AML_OBJECT_NODE_HANDLENameOpIdNode;
   CONST CHAR8 * HidString;
   CONST CHAR8 * CidString;
+  CONST CHAR8 * NonSbsaHid;
 
   // Get the _CID and _HID value to write.
   switch (SerialPortInfo->PortSubtype) {
 case EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_FULL_16550:
 {
-  HidString = "PNP0501";
-  CidString = "PNP0500";
+  // If there is a non-SBSA compliant HID, use that.
+  NonSbsaHid = (CONST CHAR8*)PcdGetPtr (PcdNonSbsaCompliantSerialHid);
+  if ((NonSbsaHid != NULL) && (AsciiStrLen (NonSbsaHid) != 0)) {
+HidString = NonSbsaHid;
+CidString = "";
+  } else {
+HidString = "PNP0501";
+CidString = "PNP0500";
+  }
   break;
 }
 case EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART:
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70590): https://edk2.groups.io/g/devel/message/70590
Mute This Topic: https://groups.io/mt/79984773/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 1/2] DynamicTablesPkg: Don't use gEfiMdeModulePkgTokenSpaceGuid

2021-01-20 Thread Joey Gouly
Introduce gEdkiiDynamicTablesPkgTokenSpaceGuid and use that instead.

Signed-off-by: Joey Gouly 
---
 DynamicTablesPkg/DynamicTablesPkg.dec  | 
10 ++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf |  
8 
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
index 
f36a6e8bb7c17f82acff3c766b15202b064a64b5..291a45a69679ae82219ecd2f26dfabfbab1f7f65
 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -1,7 +1,7 @@
 ## @file
 # dec file for Dynamic Tables Framework.
 #
-# Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -36,11 +36,13 @@ [Protocols]
 [PcdsFixedAtBuild]
 
   # Maximum number of Custom ACPI Generators
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomACPIGenerators|1|UINT16|0xC001
+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomACPIGenerators|1|UINT16|0xC001
 
   # Maximum number of Custom SMBIOS Generators
-  
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomSMBIOSGenerators|1|UINT16|0xC002
+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomSMBIOSGenerators|1|UINT16|0xC002
 
   # Maximum number of Custom DT Generators
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomDTGenerators|1|UINT16|0xC003
+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomDTGenerators|1|UINT16|0xC003
 
+[Guids]
+  gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8, 0x4613, { 0x87, 
0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } }
diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf 
b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf
index 
56b69591ac52ca3ba51250dc01a0846b22442ce9..29ed3dc2e5029206f8852c4b11240e7b493bbc57
 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf
+++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Module to manage the list of available table factories.
 #
-#  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+#  Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
@@ -41,9 +41,9 @@ [LibraryClasses]
   UefiDriverEntryPoint
 
 [FixedPcd]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomACPIGenerators
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomSMBIOSGenerators
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxCustomDTGenerators
+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomACPIGenerators
+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomSMBIOSGenerators
+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdMaxCustomDTGenerators
 
 [Protocols]
   gEdkiiDynamicTableFactoryProtocolGuid # PRODUCES
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70589): https://edk2.groups.io/g/devel/message/70589
Mute This Topic: https://groups.io/mt/79984772/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-