Re: [edk2-devel] [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser

2020-09-16 Thread Sami Mujawar
Hi Zhichao,

Thank you for the feedback.

Please find my response inline marked [SAMI].

Regards,

Sami Mujawar

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Gao, Zhichao via 
groups.io
Sent: 16 September 2020 03:44 AM
To: devel@edk2.groups.io; Sami Mujawar 
Cc: Ni, Ray ; Marc Moisson-Franckhauser 
; Guillaume Letellier 
; Matteo Carlini ; Ben 
Adderson ; nd 
Subject: Re: [edk2-devel] [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser

Hi Sami,

Sorry for the delay review. Please see below.

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Sami
> Mujawar
> Sent: Monday, August 24, 2020 6:23 PM
> To: devel@edk2.groups.io
> Cc: Sami Mujawar ; Ni, Ray ; Gao,
> Zhichao ; marc.moisson-franckhau...@arm.com;
> guillaume.letell...@arm.com; matteo.carl...@arm.com;
> ben.adder...@arm.com; n...@arm.com
> Subject: [edk2-devel] [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser
> 
> From: Marc Moisson-Franckhauser 
> 
> Create a new parser for the PCCT Table.
> 
> The PCCT Table is used to describe how the OSPM can communicate with entities
> outside the platform. It describes which memory spaces correspond to which
> entity as well as a few of the needed information to handle the 
> communications.
> 
> This new PCCT parser dumps the values and names of the table fields. It also
> performs some validation on the table's fields.
> 
> Signed-off-by: Marc Moisson-Franckhauser  franckhau...@arm.com>
> Signed-off-by: Sami Mujawar 
> ---
> 
> The changes can be seen at:
> https://github.com/samimujawar/edk2/tree/840_pcct_parser_v1
> 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> |  24 +-
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h   
> |   4
> +-
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c   
> |
> 494 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.h   
> |
> 33 ++
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
> |   4 +-
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.i
> nf |   4 +-
>  6 files changed, 558 insertions(+), 5 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> index
> f81ccac7e118378aa185db4b625e5bcd75f78347..051fdf807abb1067a264c136364
> bb6d145b38dab 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 - 2020, Arm Limited. All rights reserved.
>SPDX-License-Identifier: BSD-2-Clause-Patent  **/
> 
> @@ -671,6 +671,28 @@ ParseAcpiMcfg (
>);
> 
>  /**
> +  This function parses the ACPI PCCT table including its sub-structures
> + of type 0 through 4.
> +  When trace is enabled this function parses the PCCT table and  traces
> + the ACPI table fields.
> +
> +  This function also performs validation of the ACPI table fields.
> +
> +  @param [in] Trace  If TRUE, trace the ACPI fields.
> +  @param [in] PtrPointer to the start of the buffer.
> +  @param [in] AcpiTableLengthLength of the ACPI table.
> +  @param [in] AcpiTableRevision  Revision of the ACPI table.
> +**/
> +VOID
> +EFIAPI
> +ParseAcpiPcct (
> +  IN BOOLEAN Trace,
> +  IN UINT8*  Ptr,
> +  IN UINT32  AcpiTableLength,
> +  IN UINT8   AcpiTableRevision
> +  );
> +
> +/**
>This function parses the ACPI PPTT table.
>When trace is enabled this function parses the PPTT table and
>traces the ACPI table fields.
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> index
> 4f92596b90a6ee422d8d0959881015ffd3de4da0..19265d0b763f8a810759a2cef0
> 9ce2cc2d7bec03 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> @@ -1,7 +1,7 @@
>  /** @file
>Header file for ACPI table parser
> 
> -  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> +  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
>SPDX-License-Identifier: BSD-2-Clause-Patent  **/
> 
> @@ -11,7 +11,7 @@
>  /**
>The maximum number of ACPI table parsers.
>  */
> -#define MAX_ACPI_TABLE_PARSERS  16
> +#define MAX_ACPI_TABLE_PARSERS  17
> 
>  /** An invalid/NULL signature value.
>  */

Re: [edk2-devel] [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser

2020-09-15 Thread Gao, Zhichao
Hi Sami,

Sorry for the delay review. Please see below.

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Sami
> Mujawar
> Sent: Monday, August 24, 2020 6:23 PM
> To: devel@edk2.groups.io
> Cc: Sami Mujawar ; Ni, Ray ; Gao,
> Zhichao ; marc.moisson-franckhau...@arm.com;
> guillaume.letell...@arm.com; matteo.carl...@arm.com;
> ben.adder...@arm.com; n...@arm.com
> Subject: [edk2-devel] [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser
> 
> From: Marc Moisson-Franckhauser 
> 
> Create a new parser for the PCCT Table.
> 
> The PCCT Table is used to describe how the OSPM can communicate with entities
> outside the platform. It describes which memory spaces correspond to which
> entity as well as a few of the needed information to handle the 
> communications.
> 
> This new PCCT parser dumps the values and names of the table fields. It also
> performs some validation on the table's fields.
> 
> Signed-off-by: Marc Moisson-Franckhauser  franckhau...@arm.com>
> Signed-off-by: Sami Mujawar 
> ---
> 
> The changes can be seen at:
> https://github.com/samimujawar/edk2/tree/840_pcct_parser_v1
> 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> |  24 +-
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h   
> |   4
> +-
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c   
> |
> 494 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.h   
> |
> 33 ++
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
> |   4 +-
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.i
> nf |   4 +-
>  6 files changed, 558 insertions(+), 5 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> index
> f81ccac7e118378aa185db4b625e5bcd75f78347..051fdf807abb1067a264c136364
> bb6d145b38dab 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 - 2020, Arm Limited. All rights reserved.
>SPDX-License-Identifier: BSD-2-Clause-Patent  **/
> 
> @@ -671,6 +671,28 @@ ParseAcpiMcfg (
>);
> 
>  /**
> +  This function parses the ACPI PCCT table including its sub-structures
> + of type 0 through 4.
> +  When trace is enabled this function parses the PCCT table and  traces
> + the ACPI table fields.
> +
> +  This function also performs validation of the ACPI table fields.
> +
> +  @param [in] Trace  If TRUE, trace the ACPI fields.
> +  @param [in] PtrPointer to the start of the buffer.
> +  @param [in] AcpiTableLengthLength of the ACPI table.
> +  @param [in] AcpiTableRevision  Revision of the ACPI table.
> +**/
> +VOID
> +EFIAPI
> +ParseAcpiPcct (
> +  IN BOOLEAN Trace,
> +  IN UINT8*  Ptr,
> +  IN UINT32  AcpiTableLength,
> +  IN UINT8   AcpiTableRevision
> +  );
> +
> +/**
>This function parses the ACPI PPTT table.
>When trace is enabled this function parses the PPTT table and
>traces the ACPI table fields.
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> index
> 4f92596b90a6ee422d8d0959881015ffd3de4da0..19265d0b763f8a810759a2cef0
> 9ce2cc2d7bec03 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> @@ -1,7 +1,7 @@
>  /** @file
>Header file for ACPI table parser
> 
> -  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> +  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
>SPDX-License-Identifier: BSD-2-Clause-Patent  **/
> 
> @@ -11,7 +11,7 @@
>  /**
>The maximum number of ACPI table parsers.
>  */
> -#define MAX_ACPI_TABLE_PARSERS  16
> +#define MAX_ACPI_TABLE_PARSERS  17
> 
>  /** An invalid/NULL signature value.
>  */
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
> new file mode 100644
> index
> ..526cb7b79aa7aa6eee098246
> 00b6c7eac0ab67e2
> --- /dev/null
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctPars
> +++ er.c
> @@ -0,0 +1,494 @@
> +/** @file
>

Re: [edk2-devel] [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser

2020-09-10 Thread Gao, Zhichao
HI Sami,

Sorry, I almost forget your patches. I would review the two parser related 
patches this week.

Thanks,
Zhichao

> -Original Message-
> From: Sami Mujawar 
> Sent: Thursday, September 10, 2020 7:38 PM
> To: Gao, Zhichao ; devel@edk2.groups.io
> Cc: Ni, Ray ; Sami Mujawar ;
> Marc Moisson-Franckhauser ;
> Guillaume Letellier ; Matteo Carlini
> ; Ben Adderson ; nd
> 
> Subject: RE: [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser
> 
> Hi Zhichao,
> 
> Would it be possible for you to provide feedback for this patch, please?
> 
> Regards,
> 
> Sami Mujawar
> 
> -Original Message-
> From: Sami Mujawar 
> Sent: 24 August 2020 11:23 AM
> To: devel@edk2.groups.io
> Cc: Sami Mujawar ; ray...@intel.com;
> zhichao@intel.com; Marc Moisson-Franckhauser  franckhau...@arm.com>; Guillaume Letellier ;
> Matteo Carlini ; Ben Adderson
> ; nd 
> Subject: [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser
> 
> From: Marc Moisson-Franckhauser 
> 
> Create a new parser for the PCCT Table.
> 
> The PCCT Table is used to describe how the OSPM can communicate with entities
> outside the platform. It describes which memory spaces correspond to which
> entity as well as a few of the needed information to handle the 
> communications.
> 
> This new PCCT parser dumps the values and names of the table fields. It also
> performs some validation on the table's fields.
> 
> Signed-off-by: Marc Moisson-Franckhauser  franckhau...@arm.com>
> Signed-off-by: Sami Mujawar 
> ---
> 
> The changes can be seen at:
> https://github.com/samimujawar/edk2/tree/840_pcct_parser_v1
> 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> |  24 +-
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h   
> |   4
> +-
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c   
> |
> 494 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.h   
> |
> 33 ++
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
> |   4 +-
> 
> ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.i
> nf |   4 +-
>  6 files changed, 558 insertions(+), 5 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> index
> f81ccac7e118378aa185db4b625e5bcd75f78347..051fdf807abb1067a264c136364
> bb6d145b38dab 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 - 2020, Arm Limited. All rights reserved.
>SPDX-License-Identifier: BSD-2-Clause-Patent  **/
> 
> @@ -671,6 +671,28 @@ ParseAcpiMcfg (
>);
> 
>  /**
> +  This function parses the ACPI PCCT table including its sub-structures
> + of type 0 through 4.
> +  When trace is enabled this function parses the PCCT table and  traces
> + the ACPI table fields.
> +
> +  This function also performs validation of the ACPI table fields.
> +
> +  @param [in] Trace  If TRUE, trace the ACPI fields.
> +  @param [in] PtrPointer to the start of the buffer.
> +  @param [in] AcpiTableLengthLength of the ACPI table.
> +  @param [in] AcpiTableRevision  Revision of the ACPI table.
> +**/
> +VOID
> +EFIAPI
> +ParseAcpiPcct (
> +  IN BOOLEAN Trace,
> +  IN UINT8*  Ptr,
> +  IN UINT32  AcpiTableLength,
> +  IN UINT8   AcpiTableRevision
> +  );
> +
> +/**
>This function parses the ACPI PPTT table.
>When trace is enabled this function parses the PPTT table and
>traces the ACPI table fields.
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> index
> 4f92596b90a6ee422d8d0959881015ffd3de4da0..19265d0b763f8a810759a2cef0
> 9ce2cc2d7bec03 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
> @@ -1,7 +1,7 @@
>  /** @file
>Header file for ACPI table parser
> 
> -  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> +  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
>SPDX-License-Identifier: BSD-2-Clause-Patent  **/
> 
> @@ -11,7 +11,7 @@
>  /**
>The maximum number of ACPI table parsers.
>  */
> -#define MAX_ACPI_TABLE_PARSERS  16
> +#define MAX_ACPI_TABLE_PARSERS  17
> 
>  /** An invalid/NULL signature value.
>  */
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
> new file mode 100644
> index
> ..526cb7b79aa7aa6eee098246
> 00b6c7eac0ab67e2
> --- /dev/null
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Pars

Re: [edk2-devel] [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser

2020-09-10 Thread Sami Mujawar
Hi Zhichao,

Would it be possible for you to provide feedback for this patch, please?

Regards,

Sami Mujawar

-Original Message-
From: Sami Mujawar  
Sent: 24 August 2020 11:23 AM
To: devel@edk2.groups.io
Cc: Sami Mujawar ; ray...@intel.com; 
zhichao@intel.com; Marc Moisson-Franckhauser 
; Guillaume Letellier 
; Matteo Carlini ; Ben 
Adderson ; nd 
Subject: [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser

From: Marc Moisson-Franckhauser 

Create a new parser for the PCCT Table.

The PCCT Table is used to describe how the OSPM can
communicate with entities outside the platform. It
describes which memory spaces correspond to which
entity as well as a few of the needed information
to handle the communications.

This new PCCT parser dumps the values and names of
the table fields. It also performs some validation
on the table's fields.

Signed-off-by: Marc Moisson-Franckhauser 
Signed-off-by: Sami Mujawar 
---

The changes can be seen at:
https://github.com/samimujawar/edk2/tree/840_pcct_parser_v1

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h| 
 24 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h   | 
  4 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c   | 
494 
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.h   | 
 33 ++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c   | 
  4 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 
  4 +-
 6 files changed, 558 insertions(+), 5 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 
f81ccac7e118378aa185db4b625e5bcd75f78347..051fdf807abb1067a264c136364bb6d145b38dab
 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 - 2020, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -671,6 +671,28 @@ ParseAcpiMcfg (
   );
 
 /**
+  This function parses the ACPI PCCT table including its sub-structures
+  of type 0 through 4.
+  When trace is enabled this function parses the PCCT table and
+  traces the ACPI table fields.
+
+  This function also performs validation of the ACPI table fields.
+
+  @param [in] Trace  If TRUE, trace the ACPI fields.
+  @param [in] PtrPointer to the start of the buffer.
+  @param [in] AcpiTableLengthLength of the ACPI table.
+  @param [in] AcpiTableRevision  Revision of the ACPI table.
+**/
+VOID
+EFIAPI
+ParseAcpiPcct (
+  IN BOOLEAN Trace,
+  IN UINT8*  Ptr,
+  IN UINT32  AcpiTableLength,
+  IN UINT8   AcpiTableRevision
+  );
+
+/**
   This function parses the ACPI PPTT table.
   When trace is enabled this function parses the PPTT table and
   traces the ACPI table fields.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
index 
4f92596b90a6ee422d8d0959881015ffd3de4da0..19265d0b763f8a810759a2cef09ce2cc2d7bec03
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for ACPI table parser
 
-  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -11,7 +11,7 @@
 /**
   The maximum number of ACPI table parsers.
 */
-#define MAX_ACPI_TABLE_PARSERS  16
+#define MAX_ACPI_TABLE_PARSERS  17
 
 /** An invalid/NULL signature value.
 */
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
new file mode 100644
index 
..526cb7b79aa7aa6eee09824600b6c7eac0ab67e2
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
@@ -0,0 +1,494 @@
+/** @file
+  PCCT table parser
+
+  Copyright (c) 2020, Arm Limited.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+- ACPI 6.3 Specification - January 2019
+**/
+
+#include 
+#include 
+#include "AcpiParser.h"
+#include "AcpiView.h"
+#include "AcpiViewConfig.h"
+#include "PcctParser.h"
+
+// Local variables
+STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
+
+STATIC UINT8* PccSubspaceLength;
+STATIC UINT8* PccSubspaceType;
+
+/**
+  This function validates the length coded on 4 bytes of a shared memory range
+
+  @param [in] Ptr Pointer to the start of the field data.
+  @param [in] Context Pointer to context specific information e.g. this
+   

[edk2-devel] [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser

2020-08-24 Thread Sami Mujawar
From: Marc Moisson-Franckhauser 

Create a new parser for the PCCT Table.

The PCCT Table is used to describe how the OSPM can
communicate with entities outside the platform. It
describes which memory spaces correspond to which
entity as well as a few of the needed information
to handle the communications.

This new PCCT parser dumps the values and names of
the table fields. It also performs some validation
on the table's fields.

Signed-off-by: Marc Moisson-Franckhauser 
Signed-off-by: Sami Mujawar 
---

The changes can be seen at:
https://github.com/samimujawar/edk2/tree/840_pcct_parser_v1

 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h| 
 24 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h   | 
  4 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c   | 
494 
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.h   | 
 33 ++
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c   | 
  4 +-
 ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 
  4 +-
 6 files changed, 558 insertions(+), 5 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 
f81ccac7e118378aa185db4b625e5bcd75f78347..051fdf807abb1067a264c136364bb6d145b38dab
 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 - 2020, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -671,6 +671,28 @@ ParseAcpiMcfg (
   );
 
 /**
+  This function parses the ACPI PCCT table including its sub-structures
+  of type 0 through 4.
+  When trace is enabled this function parses the PCCT table and
+  traces the ACPI table fields.
+
+  This function also performs validation of the ACPI table fields.
+
+  @param [in] Trace  If TRUE, trace the ACPI fields.
+  @param [in] PtrPointer to the start of the buffer.
+  @param [in] AcpiTableLengthLength of the ACPI table.
+  @param [in] AcpiTableRevision  Revision of the ACPI table.
+**/
+VOID
+EFIAPI
+ParseAcpiPcct (
+  IN BOOLEAN Trace,
+  IN UINT8*  Ptr,
+  IN UINT32  AcpiTableLength,
+  IN UINT8   AcpiTableRevision
+  );
+
+/**
   This function parses the ACPI PPTT table.
   When trace is enabled this function parses the PPTT table and
   traces the ACPI table fields.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
index 
4f92596b90a6ee422d8d0959881015ffd3de4da0..19265d0b763f8a810759a2cef09ce2cc2d7bec03
 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for ACPI table parser
 
-  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -11,7 +11,7 @@
 /**
   The maximum number of ACPI table parsers.
 */
-#define MAX_ACPI_TABLE_PARSERS  16
+#define MAX_ACPI_TABLE_PARSERS  17
 
 /** An invalid/NULL signature value.
 */
diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
new file mode 100644
index 
..526cb7b79aa7aa6eee09824600b6c7eac0ab67e2
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c
@@ -0,0 +1,494 @@
+/** @file
+  PCCT table parser
+
+  Copyright (c) 2020, Arm Limited.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+- ACPI 6.3 Specification - January 2019
+**/
+
+#include 
+#include 
+#include "AcpiParser.h"
+#include "AcpiView.h"
+#include "AcpiViewConfig.h"
+#include "PcctParser.h"
+
+// Local variables
+STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
+
+STATIC UINT8* PccSubspaceLength;
+STATIC UINT8* PccSubspaceType;
+
+/**
+  This function validates the length coded on 4 bytes of a shared memory range
+
+  @param [in] Ptr Pointer to the start of the field data.
+  @param [in] Context Pointer to context specific information e.g. this
+  could be a pointer to the ACPI table header.
+**/
+STATIC
+VOID
+EFIAPI
+ValidateRangeLength4 (
+  IN UINT8* Ptr,
+  IN VOID*  Context
+  )
+{
+  if (*(UINT32*)Ptr < MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN) {
+IncrementErrorCount ();
+Print (
+  L"\nError: Shared memory range length is too short.\n"
+  L"Length is %u when it should be greater than or equal to %u",
+  *(UINT32*)Ptr,
+  MIN_EX