Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc : update build and packaging scripts to take EDK2_LIBC_PATH

2024-06-19 Thread Michael D Kinney
Reviewed-by: Michael D Kinney 

> -Original Message-
> From: Jayaprakash, N 
> Sent: Wednesday, June 19, 2024 12:53 AM
> To: devel@edk2.groups.io
> Cc: Jayaprakash, N ; Rebecca Cran
> ; Kinney, Michael D 
> Subject: [edk2-libc Patch 1/1] edk2-libc : update build and packaging scripts
> to take EDK2_LIBC_PATH
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4791
> 
> This commit adds necessary changes to build and packaging scripts
> to take path to edk2-libc through an environment variable.
> It also updates the build and packaging instructions in
> GCCCompilationBKMs.rst file and Py368ReadMe.txt files.
> The Python368.inf file is also updated to take EDK2_LIBC_PATH
> instead of the current WORKSPACE path in the CC flags.
> 
> Cc: Rebecca Cran 
> Cc: Michael D Kinney 
> Cc: Jayaprakash N 
> Signed-off-by: Jayaprakash N 
> ---
>  .../Python-3.6.8/GCCCompilationBKMs.rst   | 21 +++--
>  .../Python/Python-3.6.8/Py368ReadMe.txt   | 22 --
>  .../Python/Python-3.6.8/Python368.inf |  6 ++---
>  .../Python/Python-3.6.8/create_python_pkg.bat | 21 ++---
>  .../Python/Python-3.6.8/create_python_pkg.sh  | 23 ---
>  5 files changed, 75 insertions(+), 18 deletions(-)
> 
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
> b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
> index 0574977..667b408 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
> +++ b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
> @@ -136,17 +136,17 @@ Now clone the edk2-libc git repo by following /
> executing the below commands::
> 
>  bash$ cd ~/src
>  bash$ git clone https://github.com/tianocore/edk2-libc.git
> -bash$ export PACKAGES_PATH=$HOME/src/edk2:$HOME/src/edk2-libc
> 
> +Set the PACKAGES_PATH and EDK2_LIBC_PATH using the commands below::
> +
> +bash$ export PACKAGES_PATH=$HOME/src/edk2:$HOME/src/edk2-libc
> +bash$ export EDK2_LIBC_PATH=$HOME/src/edk2-libc
> 
>  Verify that you can build the hello world application from AppPkg under
> edk2-libc by running the following commands
>  Build hello.inf from edk2-libc applications::
> 
> -$bash build -p AppPkg/AppPkg.dsc -m
> AppPkg/Applications/Hello/Hello.inf
> -
> -Copy the contents of edk2-libc to edk2 folder::
> +$bash build -p ../edk2-libc/AppPkg/AppPkg.dsc -m ../edk2-
> libc/AppPkg/Applications/Hello/Hello.inf
> 
> -bash$ cp -rf ~/src/edk2-libc/* ~/src/edk2/
> 
>  2.5.  Build Python Interpreter using GCC
>  
> @@ -156,7 +156,8 @@ Execute the below command to build the X64 version of the
> Python 3.6.8 interpret
>  bash$ cd AppPkg/Applications/Python/Python-3.6.8/
>  bash$ python srcprep.py
>  bash$ cd ~/src/edk2
> -bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -m
> AppPkg/Applications/Python/Python-3.6.8/Python368.inf -D BUILD_PYTHON368
> +bash$ build -a X64 -b RELEASE -p ../edk2-libc/AppPkg/AppPkg.dsc \
> +  -m ../edk2-libc/AppPkg/Applications/Python/Python-
> 3.6.8/Python368.inf -D BUILD_PYTHON368
>   or
>  bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -D
> BUILD_PYTHON368
> 
> @@ -166,7 +167,13 @@ Execute the below command to build the X64 version of
> the Python 3.6.8 interpret
> 
>  To create an usable Python UEFI package with all the dependencies from the
> build environment,
>  you can use the bash shell script create_python_pkg.sh available under
> /AppPkg/Applications/Python/Python-3.6.8
> -folder.
> +folder. Ensure that EDK2_LIBC_PATH environment variable to edk2-libc folder
> path.
> +
> +Ensure that EDK2_LIBC_PATH environment variable to edk2-libc folder path::
> +
> +bash$ echo $EDK2_LIBC_PATH
> +
> +The environment variable should be set to the folder path for the edk2-libc
> cloned repo.
> 
>  Use the following commands to create Python UEFI package::
> 
> diff --git a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
> b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
> index 91f4c24..8a0b3fe 100644
> --- a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
> +++ b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
> @@ -68,7 +68,24 @@ and that you can successfully build packages within that
> distribution.
>  gc  itertools   math  _operator
>  time
> 
> -  C.  Build AppPkg using the standard "build" command:
> +  C.  Set the PACKAGES_PATH and EDK2_LIBC_PATH environment variables to
> +the right values. PACKAGES_PATH should be set to the folder path of
> +edk2 and edk2-libc folders. EDK2_LIBC_PATH should be set to the
> +folder path of edk2-libc.
> +Use the below provided commands as reference to set the environment
> +variables to the corresponding values
> +
> +set PACKAGES_PATH=;;
> + set EDK2_LIBC_PATH=
> +

[edk2-devel] Adding AArch64 support to the mu_nasm package (nasm_ext_dep.yaml)

2024-06-19 Thread Rebecca Cran
I'd like to be able to run the EDK2 CI process on my AArch64 development 
machine.


The edk2-acpica-iasl package version 20230628.0.1 has AArch64 support 
but the mu_nasm package only supports x86_64.



Could someone add AArch64 support to the mu_nasm package or tell me how 
to do so, please?


I've looked through mu_basecore and from 
BaseTools/NugetPublishing/Mu-Basetools.md it looks like it's a manual 
process? If anyone needs access to an AArch64 system I can provide a 
remote login to an Ubuntu VM.



--

Rebecca Cran



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




[edk2-devel] [staging/dynamictables-reorg PATCH 14/15] DynamicTablesPkg: FdtHwInfoParserLib: Move IRQ map to arch folder

2024-06-19 Thread PierreGondois
The interrupts-extended property in DT is arch specific.
Move the current implementation and the way to decode the property
to the Arm folder to prepare for other architecture support.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../FdtHwInfoParserLib/Arm/ArmFdtUtility.c| 85 +++
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf |  1 +
 .../Library/FdtHwInfoParserLib/FdtUtility.c   | 71 
 3 files changed, 86 insertions(+), 71 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c

diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
new file mode 100644
index ..21b1306e577d
--- /dev/null
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
@@ -0,0 +1,85 @@
+/** @file
+  Flattened device tree utility.
+
+  Copyright (c) 2021, ARM Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - Device tree Specification - Release v0.3
+  - linux/Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic.yaml
+  - 
linux//Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic.yaml
+**/
+
+#include 
+#include "FdtUtility.h"
+
+/** Get the interrupt Id of an interrupt described in a fdt.
+
+  Data must describe a GIC interrupt. A GIC interrupt is on at least
+  3 UINT32 cells.
+  This function DOES NOT SUPPORT extended SPI range and extended PPI range.
+
+  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
+
+  @retval  The interrupt id.
+**/
+UINT32
+EFIAPI
+FdtGetInterruptId (
+  UINT32 CONST  *Data
+  )
+{
+  UINT32  IrqType;
+  UINT32  IrqId;
+
+  ASSERT (Data != NULL);
+
+  IrqType = fdt32_to_cpu (Data[IRQ_TYPE_OFFSET]);
+  IrqId   = fdt32_to_cpu (Data[IRQ_NUMBER_OFFSET]);
+
+  switch (IrqType) {
+case DT_SPI_IRQ:
+  IrqId += SPI_OFFSET;
+  break;
+
+case DT_PPI_IRQ:
+  IrqId += PPI_OFFSET;
+  break;
+
+default:
+  ASSERT (0);
+  IrqId = 0;
+  }
+
+  return IrqId;
+}
+
+/** Get the ACPI interrupt flags of an interrupt described in a fdt.
+
+  Data must describe a GIC interrupt. A GIC interrupt is on at least
+  3 UINT32 cells.
+
+  PPI interrupt cpu mask on bits [15:8] are ignored.
+
+  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
+
+  @retval  The interrupt flags (for ACPI).
+**/
+UINT32
+EFIAPI
+FdtGetInterruptFlags (
+  UINT32 CONST  *Data
+  )
+{
+  UINT32  IrqFlags;
+  UINT32  AcpiIrqFlags;
+
+  ASSERT (Data != NULL);
+
+  IrqFlags = fdt32_to_cpu (Data[IRQ_FLAGS_OFFSET]);
+
+  AcpiIrqFlags  = DT_IRQ_IS_EDGE_TRIGGERED (IrqFlags) ? BIT0 : 0;
+  AcpiIrqFlags |= DT_IRQ_IS_ACTIVE_LOW (IrqFlags) ? BIT1 : 0;
+
+  return AcpiIrqFlags;
+}
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
index d3010af527c1..8e1ea100bd34 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
@@ -28,6 +28,7 @@ [Sources]
   Serial/SerialPortParser.h
 
 [Sources.ARM, Sources.AARCH64]
+  Arm/ArmFdtUtility.c
   Arm/ArmFdtHwInfoParser.c
   Arm/BootArch/ArmBootArchParser.c
   Arm/BootArch/ArmBootArchParser.h
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
index 5314cf3808c2..bab228575938 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
@@ -13,77 +13,6 @@
 #include 
 #include "FdtUtility.h"
 
-/** Get the interrupt Id of an interrupt described in a fdt.
-
-  Data must describe a GIC interrupt. A GIC interrupt is on at least
-  3 UINT32 cells.
-  This function DOES NOT SUPPORT extended SPI range and extended PPI range.
-
-  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
-
-  @retval  The interrupt id.
-**/
-UINT32
-EFIAPI
-FdtGetInterruptId (
-  UINT32 CONST  *Data
-  )
-{
-  UINT32  IrqType;
-  UINT32  IrqId;
-
-  ASSERT (Data != NULL);
-
-  IrqType = fdt32_to_cpu (Data[IRQ_TYPE_OFFSET]);
-  IrqId   = fdt32_to_cpu (Data[IRQ_NUMBER_OFFSET]);
-
-  switch (IrqType) {
-case DT_SPI_IRQ:
-  IrqId += SPI_OFFSET;
-  break;
-
-case DT_PPI_IRQ:
-  IrqId += PPI_OFFSET;
-  break;
-
-default:
-  ASSERT (0);
-  IrqId = 0;
-  }
-
-  return IrqId;
-}
-
-/** Get the ACPI interrupt flags of an interrupt described in a fdt.
-
-  Data must describe a GIC interrupt. A GIC interrupt is on at least
-  3 UINT32 cells.
-
-  PPI interrupt cpu mask on bits [15:8] are ignored.
-
-  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
-
-  @retval  The interrupt flags (for ACPI).
-**/
-UINT32
-EFIAPI
-FdtGetInterruptFlags (
-  UINT32 CONST  *Data
-  )
-{
-  UINT32  

[edk2-devel] [staging/dynamictables-reorg PATCH 15/15] DynamicTablesPkg: FdtHwInfoParserLib: Create wrapper to get INTC addr cells

2024-06-19 Thread PierreGondois
Parent interrupt controller's address cells is arch specific. So,
create a wrapper function which can be implemented differently for
different archs. Move current implementation to ARM specific file.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../AcpiSsdtPcieLib/SsdtPcieGenerator.c   |  2 +-
 .../FdtHwInfoParserLib/Arm/ArmFdtUtility.c| 33 +++
 .../Library/FdtHwInfoParserLib/FdtUtility.h   | 30 +
 .../Pci/PciConfigSpaceParser.c|  2 +-
 4 files changed, 65 insertions(+), 2 deletions(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c
index 2b488016e545..5b6d5515622b 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c
@@ -974,7 +974,7 @@ BuildSsdtPciTableEx (
   EFI_STATUSStatus;
   CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO  *PciInfo;
   UINT32PciCount;
-  UINTN Index;
+  UINT32Index;
   EFI_ACPI_DESCRIPTION_HEADER   **TableList;
   ACPI_PCI_GENERATOR*Generator;
   UINT32Uid;
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
index 21b1306e577d..71774fae7113 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
@@ -83,3 +83,36 @@ FdtGetInterruptFlags (
 
   return AcpiIrqFlags;
 }
+
+/** For relevant architectures, get the "#address-cells" and/or "#size-cells"
+property of the node.
+
+  According to the Device Tree specification, s2.3.5 "#address-cells and
+  #size-cells":
+  "If missing, a client program should assume a default value of 2 for
+  #address-cells, and a value of 1 for #size-cells."
+
+  @param [in]  Fdt  Pointer to a Flattened Device Tree.
+  @param [in]  Node Offset of the node having to get the
+"#address-cells" and "#size-cells"
+properties from.
+  @param [out] AddressCells If success, number of address-cells.
+If the property is not available,
+default value is 2.
+  @param [out] SizeCellsIf success, number of size-cells.
+If the property is not available,
+default value is 1.
+
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+FdtGetIntcAddressCells (
+  IN  CONST VOID *Fdt,
+  ININT32 Node,
+  OUT   INT32 *AddressCells, OPTIONAL
+  OUT   INT32 *SizeCells   OPTIONAL
+  )
+{
+  return FdtGetAddressInfo (Fdt, Node, AddressCells, SizeCells);
+}
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h
index 3f5d131d9ae5..2d7048753b9f 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h
@@ -455,4 +455,34 @@ FdtGetParentAddressInfo (
   OUT   INT32 *SizeCells   OPTIONAL
   );
 
+/** For relevant architectures, get the "#address-cells" and/or "#size-cells"
+property of the node.
+
+  According to the Device Tree specification, s2.3.5 "#address-cells and
+  #size-cells":
+  "If missing, a client program should assume a default value of 2 for
+  #address-cells, and a value of 1 for #size-cells."
+
+  @param [in]  Fdt  Pointer to a Flattened Device Tree.
+  @param [in]  Node Offset of the node having to get the
+"#address-cells" and "#size-cells"
+properties from.
+  @param [out] AddressCells If success, number of address-cells.
+If the property is not available,
+default value is 2.
+  @param [out] SizeCellsIf success, number of size-cells.
+If the property is not available,
+default value is 1.
+
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+FdtGetIntcAddressCells (
+  IN  CONST VOID *Fdt,
+  ININT32 Node,
+  OUT   INT32 *AddressCells, OPTIONAL
+  OUT   INT32 *SizeCells   OPTIONAL
+  );
+
 #endif // FDT_UTILITY_H_
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
index 76f9efdf64d5..7f536c0ac63e 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
+++ 

[edk2-devel] [staging/dynamictables-reorg PATCH 13/15] DynamicTablesPkg: FdtHwInfoParserLib: Move ArmLib.h to ArmGicCParser.c

2024-06-19 Thread PierreGondois
ArmLib.h is required only for building GIC in ARM. So, move it to ARM
specific file. Otherwise, FdtHwInfoParserInclude.h being a common header
across architectures will have issue on other architectures.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c   | 1 +
 .../Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h  | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c
index cf577b47242e..395521914671 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c
@@ -11,6 +11,7 @@
   - linux/Documentation/devicetree/bindings/arm/pmu.yaml
 **/
 
+#include 
 #include "FdtHwInfoParser.h"
 #include "CmObjectDescUtility.h"
 #include "Arm/Gic/ArmGicCParser.h"
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h
index 583f290095d9..60f671eccc3f 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h
@@ -10,7 +10,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.25.1



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




[edk2-devel] [staging/dynamictables-reorg PATCH 12/15] DynamicTablesPkg: FdtHwInfoParserLib: Make Serial Port parser arch neutral

2024-06-19 Thread PierreGondois
To allow other architectures to potentially re-use the serial port
parser and make the code arch neutral, remove the Arm prefixes.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c  |  2 +-
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf|  4 ++--
 ...{ArmSerialPortParser.c => SerialPortParser.c} | 16 
 ...{ArmSerialPortParser.h => SerialPortParser.h} |  8 
 4 files changed, 15 insertions(+), 15 deletions(-)
 rename 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/{ArmSerialPortParser.c => 
SerialPortParser.c} (95%)
 rename 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/{ArmSerialPortParser.h => 
SerialPortParser.h} (89%)

diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
index 49a7636dad0a..2c9105ed1023 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
@@ -10,7 +10,7 @@
 #include "Arm/GenericTimer/ArmGenericTimerParser.h"
 #include "Arm/Gic/ArmGicDispatcher.h"
 #include "Pci/PciConfigSpaceParser.h"
-#include "Serial/ArmSerialPortParser.h"
+#include "Serial/SerialPortParser.h"
 
 /** Ordered table of parsers/dispatchers.
 
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
index 55ec7d97fa18..d3010af527c1 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
@@ -24,8 +24,8 @@ [Sources]
   FdtUtility.h
   Pci/PciConfigSpaceParser.c
   Pci/PciConfigSpaceParser.h
-  Serial/ArmSerialPortParser.c
-  Serial/ArmSerialPortParser.h
+  Serial/SerialPortParser.c
+  Serial/SerialPortParser.h
 
 [Sources.ARM, Sources.AARCH64]
   Arm/ArmFdtHwInfoParser.c
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c
similarity index 95%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.c
rename to DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c
index f17ad2e842e2..2d0dccea3d3a 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c
@@ -1,5 +1,5 @@
 /** @file
-  Arm Serial Port Parser.
+  Serial Port Parser.
 
   Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -15,7 +15,7 @@
 
 #include "CmObjectDescUtility.h"
 #include "FdtHwInfoParser.h"
-#include "Serial/ArmSerialPortParser.h"
+#include "Serial/SerialPortParser.h"
 
 /** List of "compatible" property values for serial port nodes.
 
@@ -329,7 +329,7 @@ GetSerialConsoleNode (
 STATIC
 EFI_STATUS
 EFIAPI
-ArmSerialPortInfoDispatch (
+SerialPortInfoDispatch (
   IN  CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
   IN  CM_ARCH_COMMON_SERIAL_PORT_INFO  *GenericSerialInfo,
   IN  INT32NodeCount,
@@ -408,7 +408,7 @@ ArmSerialPortInfoDispatch (
 STATIC
 EFI_STATUS
 EFIAPI
-ArmSerialPortInfoParser (
+SerialPortInfoParser (
   IN  CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
   ININT32  FdtBranch,
   INEARCH_COMMON_OBJECT_ID SerialObjectId
@@ -436,7 +436,7 @@ ArmSerialPortInfoParser (
 return Status;
   }
 
-  Status = ArmSerialPortInfoDispatch (
+  Status = SerialPortInfoDispatch (
  FdtParserHandle,
  ,
  1,
@@ -529,7 +529,7 @@ SerialPortDispatcher (
 return Status;
   } else {
 // Parse the console serial-port.
-Status = ArmSerialPortInfoParser (
+Status = SerialPortInfoParser (
FdtParserHandle,
SerialConsoleNode,
EArchCommonObjConsolePortInfo
@@ -587,7 +587,7 @@ SerialPortDispatcher (
   // The first serial-port node, not being the console serial-port,
   // will be the debug serial-port.
   SerialDebugNode = SerialNode;
-  Status  = ArmSerialPortInfoParser (
+  Status  = SerialPortInfoParser (
   FdtParserHandle,
   SerialDebugNode,
   EArchCommonObjSerialDebugPortInfo
@@ -617,7 +617,7 @@ SerialPortDispatcher (
   } // for
 
   if (GenericSerialIndex > 0) {
-Status = ArmSerialPortInfoDispatch (
+Status = SerialPortInfoDispatch (
FdtParserHandle,
GenericSerialInfo,
GenericSerialIndex,
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/ArmSerialPortParser.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.h
similarity index 89%
rename from 

[edk2-devel] [staging/dynamictables-reorg PATCH 10/15] DynamicTablesPkg: FdtHwInfoParserLib: Refactor to prepare for other archs

2024-06-19 Thread PierreGondois
To allow other architectures to potentially re-use the serial port
parser and make the code arch neutral, make the MainDispatcher()
function arch specific.

Other architectures can choose which parse/dispatcher are desired
to be called through the configuration of the HwInfoParserTable.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../Arm/ArmFdtHwInfoParser.c  | 83 +++
 .../FdtHwInfoParserLib/FdtHwInfoParser.c  | 78 +
 .../FdtHwInfoParserLib/FdtHwInfoParser.h  | 27 ++
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf | 15 ++--
 4 files changed, 121 insertions(+), 82 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c

diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
new file mode 100644
index ..403402731add
--- /dev/null
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
@@ -0,0 +1,83 @@
+/** @file
+  Arm Flattened Device Tree parser library for KvmTool.
+
+  Copyright (c) 2021, ARM Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "FdtHwInfoParser.h"
+#include "Arm/BootArch/ArmBootArchParser.h"
+#include "Arm/GenericTimer/ArmGenericTimerParser.h"
+#include "Arm/Gic/ArmGicDispatcher.h"
+#include "Pci/ArmPciConfigSpaceParser.h"
+#include "Serial/ArmSerialPortParser.h"
+
+/** Ordered table of parsers/dispatchers.
+
+  A parser parses a Device Tree to populate a specific CmObj type. None,
+  one or many CmObj can be created by the parser.
+  The created CmObj are then handed to the parser's caller through the
+  HW_INFO_ADD_OBJECT interface.
+  This can also be a dispatcher. I.e. a function that not parsing a
+  Device Tree but calling other parsers.
+*/
+STATIC CONST FDT_HW_INFO_PARSER_FUNC  HwInfoParserTable[] = {
+  ArmBootArchInfoParser,
+  ArmGenericTimerInfoParser,
+  ArmGicDispatcher,
+  ArmPciConfigInfoParser,
+  SerialPortDispatcher
+};
+
+/** Main dispatcher: sequentially call the parsers/dispatchers
+of the HwInfoParserTable.
+
+  A parser parses a Device Tree to populate a specific CmObj type. None,
+  one or many CmObj can be created by the parser.
+  The created CmObj are then handed to the parser's caller through the
+  HW_INFO_ADD_OBJECT interface.
+  This can also be a dispatcher. I.e. a function that not parsing a
+  Device Tree but calling other parsers.
+
+  @param [in]  FdtParserHandle A handle to the parser instance.
+  @param [in]  FdtBranch   When searching for DT node name, restrict
+   the search to this Device Tree branch.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_ABORTED An error occurred.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_NOT_FOUND   Not found.
+  @retval EFI_UNSUPPORTED Unsupported.
+**/
+EFI_STATUS
+EFIAPI
+ArchFdtHwInfoMainDispatcher (
+  IN  CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
+  ININT32  FdtBranch
+  )
+{
+  EFI_STATUS  Status;
+  UINT32  Index;
+
+  if (fdt_check_header (FdtParserHandle->Fdt) < 0) {
+ASSERT (0);
+return EFI_INVALID_PARAMETER;
+  }
+
+  for (Index = 0; Index < ARRAY_SIZE (HwInfoParserTable); Index++) {
+Status = HwInfoParserTable[Index](
+  FdtParserHandle,
+  FdtBranch
+  );
+if (EFI_ERROR (Status)  &&
+(Status != EFI_NOT_FOUND))
+{
+  // If EFI_NOT_FOUND, the parser didn't find information in the DT.
+  // Don't trigger an error.
+  ASSERT (0);
+  return Status;
+}
+  } // for
+
+  return EFI_SUCCESS;
+}
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c
index 78bf9c9efae4..8e980dabe373 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c
@@ -6,82 +6,6 @@
 **/
 
 #include "FdtHwInfoParser.h"
-#include "Arm/BootArch/ArmBootArchParser.h"
-#include "Arm/GenericTimer/ArmGenericTimerParser.h"
-#include "Arm/Gic/ArmGicDispatcher.h"
-#include "Pci/ArmPciConfigSpaceParser.h"
-#include "Serial/ArmSerialPortParser.h"
-
-/** Ordered table of parsers/dispatchers.
-
-  A parser parses a Device Tree to populate a specific CmObj type. None,
-  one or many CmObj can be created by the parser.
-  The created CmObj are then handed to the parser's caller through the
-  HW_INFO_ADD_OBJECT interface.
-  This can also be a dispatcher. I.e. a function that not parsing a
-  Device Tree but calling other parsers.
-*/
-STATIC CONST FDT_HW_INFO_PARSER_FUNC  HwInfoParserTable[] = {
-  ArmBootArchInfoParser,
-  ArmGenericTimerInfoParser,
-  ArmGicDispatcher,
-  

[edk2-devel] [staging/dynamictables-reorg PATCH 11/15] DynamicTablesPkg: FdtHwInfoParserLib: Make Pci parser arch neutral

2024-06-19 Thread PierreGondois
To allow other architectures to potentially re-use the serial port
parser and make the code arch neutral, remove the Arm prefixes.
Also remove the check searching for a GIC version.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c |  4 ++--
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf   |  4 ++--
 ...nfigSpaceParser.c => PciConfigSpaceParser.c} | 17 -
 ...nfigSpaceParser.h => PciConfigSpaceParser.h} | 10 +-
 4 files changed, 13 insertions(+), 22 deletions(-)
 rename 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/{ArmPciConfigSpaceParser.c => 
PciConfigSpaceParser.c} (95%)
 rename 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/{ArmPciConfigSpaceParser.h => 
PciConfigSpaceParser.h} (93%)

diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
index 403402731add..49a7636dad0a 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
@@ -9,7 +9,7 @@
 #include "Arm/BootArch/ArmBootArchParser.h"
 #include "Arm/GenericTimer/ArmGenericTimerParser.h"
 #include "Arm/Gic/ArmGicDispatcher.h"
-#include "Pci/ArmPciConfigSpaceParser.h"
+#include "Pci/PciConfigSpaceParser.h"
 #include "Serial/ArmSerialPortParser.h"
 
 /** Ordered table of parsers/dispatchers.
@@ -25,7 +25,7 @@ STATIC CONST FDT_HW_INFO_PARSER_FUNC  HwInfoParserTable[] = {
   ArmBootArchInfoParser,
   ArmGenericTimerInfoParser,
   ArmGicDispatcher,
-  ArmPciConfigInfoParser,
+  PciConfigInfoParser,
   SerialPortDispatcher
 };
 
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
index 3abc6a0fd274..55ec7d97fa18 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
@@ -22,8 +22,8 @@ [Sources]
   FdtHwInfoParser.h
   FdtUtility.c
   FdtUtility.h
-  Pci/ArmPciConfigSpaceParser.c
-  Pci/ArmPciConfigSpaceParser.h
+  Pci/PciConfigSpaceParser.c
+  Pci/PciConfigSpaceParser.h
   Serial/ArmSerialPortParser.c
   Serial/ArmSerialPortParser.h
 
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
similarity index 95%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.c
rename to DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
index 5d11863dfe0a..76f9efdf64d5 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
@@ -1,5 +1,5 @@
 /** @file
-  Arm PCI Configuration Space Parser.
+  PCI Configuration Space Parser.
 
   Copyright (c) 2021, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -16,8 +16,7 @@
 #include 
 
 #include "FdtHwInfoParser.h"
-#include "Pci/ArmPciConfigSpaceParser.h"
-#include "Arm/Gic/ArmGicDispatcher.h"
+#include "Pci/PciConfigSpaceParser.h"
 
 /** List of "compatible" property values for host PCIe bridges nodes.
 
@@ -306,8 +305,7 @@ ParseIrqMap (
   CONST UINT8  *IrqMapMask;
   INT32IrqMapMaskSize;
 
-  INT32   PHandleOffset;
-  UINT32  GicVersion;
+  INT32  PHandleOffset;
 
   UINT32  PciAddressAttr;
 
@@ -366,13 +364,6 @@ ParseIrqMap (
 return EFI_ABORTED;
   }
 
-  // Only support Gic(s) for now.
-  Status = GetGicVersion (Fdt, IntcNode, );
-  if (EFI_ERROR (Status)) {
-ASSERT (0);
-return Status;
-  }
-
   // Get the "address-cells" property of the IntcNode.
   Status = FdtGetAddressInfo (Fdt, IntcNode, , NULL);
   if (EFI_ERROR (Status)) {
@@ -727,7 +718,7 @@ FreeParserTable (
 **/
 EFI_STATUS
 EFIAPI
-ArmPciConfigInfoParser (
+PciConfigInfoParser (
   IN  CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
   ININT32  FdtBranch
   )
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.h
similarity index 93%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.h
rename to DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.h
index e68013838515..aeffe7ac3501 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/ArmPciConfigSpaceParser.h
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.h
@@ -1,5 +1,5 @@
 /** @file
-  Arm PCI Configuration Space Parser.
+  PCI Configuration Space Parser.
 
   Copyright (c) 2021, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -12,8 +12,8 @@
   - linux kernel code
 **/
 
-#ifndef ARM_PCI_CONFIG_SPACE_PARSER_H_
-#define ARM_PCI_CONFIG_SPACE_PARSER_H_
+#ifndef 

[edk2-devel] [staging/dynamictables-reorg PATCH 09/15] DynamicTablesPkg: FdtHwInfoParserLib: Move ARM parsers to Arm directory

2024-06-19 Thread PierreGondois
Create an Arm directory in the FdtHwInfoParserLib as a preparation
step to support other architectures.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../{ => Arm}/BootArch/ArmBootArchParser.c|  2 +-
 .../{ => Arm}/BootArch/ArmBootArchParser.h|  0
 .../GenericTimer/ArmGenericTimerParser.c  |  4 +--
 .../GenericTimer/ArmGenericTimerParser.h  |  0
 .../{ => Arm}/Gic/ArmGicCParser.c |  4 +--
 .../{ => Arm}/Gic/ArmGicCParser.h |  0
 .../{ => Arm}/Gic/ArmGicDParser.c |  4 +--
 .../{ => Arm}/Gic/ArmGicDParser.h |  0
 .../{ => Arm}/Gic/ArmGicDispatcher.c  | 12 +++
 .../{ => Arm}/Gic/ArmGicDispatcher.h  |  0
 .../{ => Arm}/Gic/ArmGicItsParser.c   |  4 +--
 .../{ => Arm}/Gic/ArmGicItsParser.h   |  0
 .../{ => Arm}/Gic/ArmGicMsiFrameParser.c  |  4 +--
 .../{ => Arm}/Gic/ArmGicMsiFrameParser.h  |  0
 .../{ => Arm}/Gic/ArmGicRParser.c |  4 +--
 .../{ => Arm}/Gic/ArmGicRParser.h |  0
 .../FdtHwInfoParserLib/FdtHwInfoParser.c  |  6 ++--
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf | 32 +--
 .../Pci/ArmPciConfigSpaceParser.c |  2 +-
 19 files changed, 39 insertions(+), 39 deletions(-)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/BootArch/ArmBootArchParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/BootArch/ArmBootArchParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/GenericTimer/ArmGenericTimerParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/GenericTimer/ArmGenericTimerParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicCParser.c (96%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicCParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicDParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicDParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicDispatcher.c (92%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicDispatcher.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicItsParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicItsParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicMsiFrameParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicMsiFrameParser.h (100%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicRParser.c (95%)
 rename DynamicTablesPkg/Library/FdtHwInfoParserLib/{ => 
Arm}/Gic/ArmGicRParser.h (100%)

diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/BootArch/ArmBootArchParser.c 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c
similarity index 95%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/BootArch/ArmBootArchParser.c
rename to 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c
index b07b6b8b666a..d217e33424b1 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/BootArch/ArmBootArchParser.c
+++ 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c
@@ -10,7 +10,7 @@
 
 #include "FdtHwInfoParser.h"
 #include "CmObjectDescUtility.h"
-#include "BootArch/ArmBootArchParser.h"
+#include "Arm/BootArch/ArmBootArchParser.h"
 
 /** List of "compatible" property values for Psci nodes.
 
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/BootArch/ArmBootArchParser.h 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.h
similarity index 100%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/BootArch/ArmBootArchParser.h
rename to 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.h
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/GenericTimer/ArmGenericTimerParser.c
 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/GenericTimer/ArmGenericTimerParser.c
similarity index 95%
rename from 
DynamicTablesPkg/Library/FdtHwInfoParserLib/GenericTimer/ArmGenericTimerParser.c
rename to 
DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/GenericTimer/ArmGenericTimerParser.c
index 988a81221dab..6488399ed812 100644
--- 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/GenericTimer/ArmGenericTimerParser.c
+++ 
b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/GenericTimer/ArmGenericTimerParser.c
@@ -10,8 +10,8 @@
 
 #include "FdtHwInfoParser.h"
 #include "CmObjectDescUtility.h"
-#include "GenericTimer/ArmGenericTimerParser.h"
-#include "Gic/ArmGicDispatcher.h"
+#include "Arm/GenericTimer/ArmGenericTimerParser.h"
+#include "Arm/Gic/ArmGicDispatcher.h"
 
 /** List of "compatible" property values for timer nodes.
 
diff --git 
a/DynamicTablesPkg/Library/FdtHwInfoParserLib/GenericTimer/ArmGenericTimerParser.h
 

[edk2-devel] [staging/dynamictables-reorg PATCH 07/15] DynamicTablesPkg: AcpiSsdtCpuTopologyLib: Avoid dependency on GICC

2024-06-19 Thread PierreGondois
The GICC is an ARM specific structure. Other architectures have different
local interrupt controller structures from which CPU topology can be
created. Avoid the GICC reference in common code by:
- creating a wrapper CreateTopologyFromIntC() instead of
  CreateTopologyFromGicC() so that different archs can implement
  it differently.
- implementing arch specific functions to get the AcpiProcessorUid,
  CpcToken, EtToken and use them instead of using the GicC CM object
  directly.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../Arm/ArmSsdtCpuTopologyGenerator.c | 408 ++
 .../SsdtCpuTopologyGenerator.c| 341 ++-
 .../SsdtCpuTopologyGenerator.h| 196 +
 .../SsdtCpuTopologyLib.inf|   3 +
 4 files changed, 647 insertions(+), 301 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/Arm/ArmSsdtCpuTopologyGenerator.c

diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/Arm/ArmSsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/Arm/ArmSsdtCpuTopologyGenerator.c
new file mode 100644
index ..140a2e491116
--- /dev/null
+++ 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/Arm/ArmSsdtCpuTopologyGenerator.c
@@ -0,0 +1,408 @@
+/** @file
+  ARM SSDT Cpu Topology Table Generator Helpers.
+
+  Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+- ACPI 6.3 Specification - January 2019 - s8.4 Declaring Processors
+- ACPI for CoreSight version 1.2 Platform Design Document
+  (https://developer.arm.com/documentation/den0067/a/?lang=en)
+
+  @par Glossary:
+- ETE - Embedded Trace Extension.
+- ETM - Embedded Trace Macrocell.
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "SsdtCpuTopologyGenerator.h"
+
+/** ARM SSDT Cpu Topology Table Generator.
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjGicCInfo
+  - EArmObjEtInfo (OPTIONAL)
+*/
+
+/** This macro expands to a function that retrieves the GIC
+CPU interface Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGicCInfo,
+  CM_ARM_GICC_INFO
+  );
+
+/**
+  This macro expands to a function that retrieves the ET device
+  information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjEtInfo,
+  CM_ARM_ET_INFO
+  );
+
+/** Create an embedded trace device and add it to the Cpu Node in the
+AML namespace.
+
+  This generates the following ASL code:
+  Device (E002)
+  {
+  Name (_UID, 2)
+  Name (_HID, "ARMHC500")
+  }
+
+  Note: Currently we only support generating ETE nodes. Unlike ETM,
+  ETE has a system register interface and therefore does not need
+  the MMIO range to be described.
+
+  @param [in]  GeneratorThe SSDT Cpu Topology generator.
+  @param [in]  ParentNode   Parent node to attach the Cpu node to.
+  @param [in]  AcpiProcessorUid ACPI Processor UID of the CPU.
+  @param [in]  CpuName  Value used to generate the node name.
+  @param [out] EtNodePtrIf not NULL, return the created Cpu node.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+CreateAmlEtd (
+  IN   ACPI_CPU_TOPOLOGY_GENERATOR  *Generator,
+  IN   AML_NODE_HANDLE  ParentNode,
+  IN   UINT32   AcpiProcessorUid,
+  IN   UINT32   CpuName,
+  OUT  AML_OBJECT_NODE_HANDLE   *EtNodePtr OPTIONAL
+  )
+{
+  EFI_STATUS  Status;
+  AML_OBJECT_NODE_HANDLE  EtNode;
+  CHAR8   AslName[AML_NAME_SEG_SIZE + 1];
+
+  ASSERT (Generator != NULL);
+  ASSERT (ParentNode != NULL);
+
+  Status = WriteAslName ('E', CpuName, AslName);
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+return Status;
+  }
+
+  Status = AmlCodeGenDevice (AslName, ParentNode, );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+return Status;
+  }
+
+  Status = AmlCodeGenNameInteger (
+ "_UID",
+ AcpiProcessorUid,
+ EtNode,
+ NULL
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+return Status;
+  }
+
+  Status = AmlCodeGenNameString (
+ "_HID",
+ ACPI_HID_ET_DEVICE,
+ EtNode,
+ NULL
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT (0);
+return Status;
+  }
+
+  // If requested, return the handle to the EtNode.
+  if (EtNodePtr != NULL) {
+*EtNodePtr = EtNode;
+  }
+
+  return Status;
+}
+
+/** Create and 

[edk2-devel] [staging/dynamictables-reorg PATCH 08/15] DynamicTablesPkg: DynamicTableManagerDxe: Refactor PresenceArray

2024-06-19 Thread PierreGondois
Mandatory ACPI tables depend on the architectures.
Different architectures might also want to check other tables.

Move mAcpiVerifyTables containing the list of ACPI tables to check
to an arch specific file and introduce GetAcpiTablePresenceInfo()
to get get the relevant information from the array.

Signed-off-by: Pierre Gondois 
---
 .../Arm/ArmDynamicTableManagerDxe.c   | 63 +
 .../Common/CommonDynamicTableManagerDxe.c | 58 +++
 .../DynamicTableManagerDxe.c  | 70 ++-
 .../DynamicTableManagerDxe.h  | 63 +
 .../DynamicTableManagerDxe.inf|  7 ++
 5 files changed, 211 insertions(+), 50 deletions(-)
 create mode 100644 
DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamicTableManagerDxe.c
 create mode 100644 
DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Common/CommonDynamicTableManagerDxe.c
 create mode 100644 
DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.h

diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamicTableManagerDxe.c
 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamicTableManagerDxe.c
new file mode 100644
index ..4874fe883f95
--- /dev/null
+++ 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Arm/ArmDynamicTableManagerDxe.c
@@ -0,0 +1,63 @@
+/** @file
+  ARM Dynamic Table Manager Dxe
+
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "DynamicTableManagerDxe.h"
+
+///
+/// Array containing the ACPI tables to check.
+/// We require the FADT, MADT, GTDT and the DSDT tables to boot.
+/// This list also include optional ACPI tables: DBG2, SPCR.
+/// The FADT table must be placed at index 0.
+///
+STATIC ACPI_TABLE_PRESENCE_INFO  mAcpiVerifyTables[] = {
+  { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,  
  "FADT", TRUE,  0 },
+  { EStdAcpiTableIdMadt, 
EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, "MADT", TRUE,  
0 },
+  { EStdAcpiTableIdGtdt, 
EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, "GTDT", TRUE,  
0 },
+  { EStdAcpiTableIdDsdt, 
EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, "DSDT", TRUE,  
0 },
+  { EStdAcpiTableIdDbg2, EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE,
  "DBG2", FALSE, 0 },
+  { EStdAcpiTableIdSpcr, 
EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,   "SPCR", FALSE, 
0 },
+};
+
+/** Get the arch specific ACPI table presence information.
+
+  @param [out] PresenceArray  Array containing the ACPI tables to check.
+  @param [out] PresenceArrayCount Count of elements in the PresenceArray.
+  @param [out] FadtIndex  Index of the FADT table in the PresenceArray.
+  -1 if absent.
+
+  @retval EFI_SUCCESS   Success.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiTablePresenceInfo (
+  OUT ACPI_TABLE_PRESENCE_INFO  **PresenceArray,
+  OUT UINT32*PresenceArrayCount,
+  OUT INT32 *FadtIndex
+  )
+{
+  *PresenceArray  = mAcpiVerifyTables;
+  *PresenceArrayCount = ARRAY_SIZE (mAcpiVerifyTables);
+  *FadtIndex  = ACPI_TABLE_VERIFY_FADT;
+
+  return EFI_SUCCESS;
+}
diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Common/CommonDynamicTableManagerDxe.c
 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Common/CommonDynamicTableManagerDxe.c
new file mode 100644
index ..cb6bf72f31ab
--- /dev/null
+++ 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/Common/CommonDynamicTableManagerDxe.c
@@ -0,0 +1,58 @@
+/** @file
+  Common Dynamic Table Manager Dxe
+
+  Copyright (c) 2024, Arm Limited. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "DynamicTableManagerDxe.h"
+
+///
+/// Array containing the ACPI tables to check.
+/// This is a dummy list only existing for build purpose.
+/// The FADT table must be placed at index 0.
+///
+ACPI_TABLE_PRESENCE_INFO  mAcpiVerifyTables[] = {
+  { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, 
"FADT", TRUE, 0 },
+};
+
+/** Get the arch specific ACPI table presence information.
+
+  @param [out] PresenceArray  Array containing the ACPI tables to check.
+  @param [out] PresenceArrayCount Count of elements in the PresenceArray.
+  @param [out] FadtIndex  Index of the FADT table in the PresenceArray.
+  -1 if absent.
+
+  @retval EFI_SUCCESS   Success.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiTablePresenceInfo 

[edk2-devel] [staging/dynamictables-reorg PATCH 06/15] DynamicTablesPkg: AcpiSratLib: Prepare to support other archs

2024-06-19 Thread PierreGondois
Allow other architectures to reuse the AcpiSratLib by extracting
the Arm specific part of the table generation.

Signed-off-by: Pierre Gondois 
---
 .../Acpi/Common/AcpiSratLib/AcpiSratLib.inf   |   7 +
 .../Common/AcpiSratLib/Arm/ArmSratGenerator.c | 262 ++
 .../AcpiSratLib/Common/CommonSratGenerator.c  |  77 +
 .../Acpi/Common/AcpiSratLib/SratGenerator.c   | 214 ++
 .../Acpi/Common/AcpiSratLib/SratGenerator.h   |  59 
 5 files changed, 422 insertions(+), 197 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Arm/ArmSratGenerator.c
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Common/CommonSratGenerator.c
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/SratGenerator.h

diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/AcpiSratLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/AcpiSratLib.inf
index 2f23f4e668e5..c2f24a23ccd8 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/AcpiSratLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/AcpiSratLib.inf
@@ -18,6 +18,13 @@ [Defines]
 
 [Sources]
   SratGenerator.c
+  SratGenerator.h
+
+[Sources.ARM, Sources.AARCH64]
+  Arm/ArmSratGenerator.c
+
+[Sources.IA32, Sources.X64]
+  Common/CommonSratGenerator.c
 
 [Packages]
   EmbeddedPkg/EmbeddedPkg.dec
diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Arm/ArmSratGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Arm/ArmSratGenerator.c
new file mode 100644
index ..3d36b25e1840
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSratLib/Arm/ArmSratGenerator.c
@@ -0,0 +1,262 @@
+/** @file
+  Arm SRAT Table Generator
+
+  Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - ACPI 6.3 Specification, January 2019
+
+  @par Glossary:
+  - Cm or CM   - Configuration Manager
+  - Obj or OBJ - Object
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "SratGenerator.h"
+
+/**
+  ARM standard SRAT Generator
+
+  Requirements:
+The following Configuration Manager Object(s) are used by this Generator:
+- EArmObjGicCInfo (REQUIRED)
+- EArmObjGicItsInfo (OPTIONAL)
+*/
+
+/** This macro expands to a function that retrieves the GIC
+CPU interface Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGicCInfo,
+  CM_ARM_GICC_INFO
+  );
+
+/** This macro expands to a function that retrieves the GIC
+Interrupt Translation Service Information from the
+Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGicItsInfo,
+  CM_ARM_GIC_ITS_INFO
+  );
+
+/** Enum of the Arm specific CM objects required to
+build the arch specific information of the SRAT table.
+*/
+typedef enum ArmSratSubTableType {
+  EArmGicCSubTableType,
+  EArmGicItsSubTableType,
+  EArmSubTableTypeMax,
+} EARM_SRAT_SUB_TABLE_TYPE;
+
+typedef struct SratSubTable {
+  /// Start offset of the arch specific sub-table.
+  UINT32Offset;
+
+  /// Count
+  UINT32Count;
+
+  /// Array of CmInfo objects of the relevant type.
+  VOID  *CmInfo;
+} SRAT_SUB_TABLE;
+
+STATIC SRAT_SUB_TABLE  mSratSubTable[EArmSubTableTypeMax];
+
+/** Reserve arch sub-tables space.
+
+  @param [in] CfgMgrProtocol   Pointer to the Configuration Manager
+  @param [in, out] ArchOffset  On input, contains the offset where arch 
specific
+   sub-tables can be written. It is expected that
+   there enough space to write all the arch 
specific
+   sub-tables from this offset onward.
+   On ouput, contains the ending offset of the arch
+   specific sub-tables.
+
+  @retval EFI_SUCCESS   Table generated successfully.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object information is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size for the
+requested object.
+**/
+EFI_STATUS
+EFIAPI
+ArchReserveOffsets (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN OUT UINT32   *ArchOffset
+  )
+{
+  EFI_STATUS  Status;
+
+  ASSERT (CfgMgrProtocol != NULL);
+  ASSERT (ArchOffset != NULL);
+
+  Status = GetEArmObjGicCInfo (
+ CfgMgrProtocol,
+ CM_NULL_TOKEN,
+ (CM_ARM_GICC_INFO **)[EArmGicCSubTableType].CmInfo,
+ [EArmGicCSubTableType].Count
+ );
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "ERROR: SRAT: Failed to get GICC Info. Status = 

[edk2-devel] [staging/dynamictables-reorg PATCH 05/15] DynamicTablesPkg: AcpiSpcrLib: Prepare to support other archs

2024-06-19 Thread PierreGondois
Remove the Arm name from the generator to show the generator
can be used by other archs.

Signed-off-by: Pierre Gondois 
---
 .../Library/Acpi/Common/AcpiSpcrLib/SpcrGenerator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSpcrLib/SpcrGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiSpcrLib/SpcrGenerator.c
index 6f027f3bf941..065729d7eecf 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSpcrLib/SpcrGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSpcrLib/SpcrGenerator.c
@@ -26,7 +26,7 @@
 #include 
 #include 
 
-/** ARM standard SPCR Table Generator
+/** Standard SPCR Table Generator
 
   Constructs the SPCR table for PL011 or SBSA UART peripherals.
 
-- 
2.25.1



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




[edk2-devel] [staging/dynamictables-reorg PATCH 03/15] DynamicTablesPkg: AcpiFadtLib: Prepare to support other archs

2024-06-19 Thread PierreGondois
Allow other architectures to reuse the AcpiFadtLib by extracting
the Arm specific part of the table generation.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf   |   7 +
 .../Common/AcpiFadtLib/Arm/ArmFadtGenerator.c | 126 ++
 .../AcpiFadtLib/Common/CommonFadtGenerator.c  |  46 +++
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.c   |  86 ++--
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.h   |  35 +
 5 files changed, 224 insertions(+), 76 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGenerator.c
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Common/CommonFadtGenerator.c
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h

diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
index c9cd850faac0..be2af0cfd53a 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
@@ -18,6 +18,13 @@ [Defines]
 
 [Sources]
   FadtGenerator.c
+  FadtGenerator.h
+
+[Sources.ARM, Sources.AARCH64]
+  Arm/ArmFadtGenerator.c
+
+[Sources.IA32, Sources.X64]
+  Common/CommonFadtGenerator.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGenerator.c
new file mode 100644
index ..2d2afe98ab1f
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGenerator.c
@@ -0,0 +1,126 @@
+/** @file
+  ARM FADT Table Helpers
+
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - ACPI 6.5 Specification, Aug 29, 2022
+
+**/
+
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "FadtGenerator.h"
+
+/** ARM Standard FADT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjBootArchInfo
+*/
+
+/** This macro expands to a function that retrieves the Boot
+Architecture Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjBootArchInfo,
+  CM_ARM_BOOT_ARCH_INFO
+  );
+
+/** This macro defines the FADT flag options for ARM Platforms.
+*/
+#define FADT_FLAGS  (EFI_ACPI_6_5_HW_REDUCED_ACPI |  \
+ EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE)
+
+/** Updates the Architecture specific information in the FADT Table.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+  Protocol Interface.
+  @param [in, out] Fadt   Pointer to the constructed ACPI Table.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object was not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size for the
+requested object.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+ArmFadtBootArchInfoUpdate (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN   OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE  *Fadt
+  )
+{
+  EFI_STATUS Status;
+  CM_ARM_BOOT_ARCH_INFO  *BootArchInfo;
+
+  ASSERT (CfgMgrProtocol != NULL);
+  ASSERT (Fadt != NULL);
+
+  // Get the Boot Architecture flags from the Platform Configuration Manager
+  Status = GetEArmObjBootArchInfo (
+ CfgMgrProtocol,
+ CM_NULL_TOKEN,
+ ,
+ NULL
+ );
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "ERROR: FADT: Failed to get Boot Architecture flags. Status = %r\n",
+  Status
+  ));
+return Status;
+  }
+
+  DEBUG ((
+DEBUG_INFO,
+"FADT BootArchFlag = 0x%x\n",
+BootArchInfo->BootArchFlags
+));
+
+  Fadt->ArmBootArch = BootArchInfo->BootArchFlags;
+
+  return Status;
+}
+
+/** Updates the Architecture specific information in the FADT Table.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+  Protocol Interface.
+  @param [in, out] Fadt   Pointer to the constructed ACPI Table.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object was not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size for the
+requested object.
+**/
+EFI_STATUS
+EFIAPI
+FadtArchUpdate (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  

[edk2-devel] [staging/dynamictables-reorg PATCH 04/15] DynamicTablesPkg: AcpiDbg2Lib: Prepare to support other archs

2024-06-19 Thread PierreGondois
Allow other architectures to reuse the AcpiDbg2Lib by extracting
the Arm specific part of the table generation.

Signed-off-by: Pierre Gondois 
---
 .../Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf   |  7 ++
 .../Common/AcpiDbg2Lib/Arm/ArmDbg2Generator.c | 67 +++
 .../AcpiDbg2Lib/Common/CommonDbg2Generator.c  | 59 
 .../Acpi/Common/AcpiDbg2Lib/Dbg2Generator.c   | 24 +--
 .../Acpi/Common/AcpiDbg2Lib/Dbg2Generator.h   | 56 
 5 files changed, 206 insertions(+), 7 deletions(-)
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Arm/ArmDbg2Generator.c
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Common/CommonDbg2Generator.c
 create mode 100644 
DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Dbg2Generator.h

diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf
index 32dcd20c082b..1e0ce347c0fa 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf
@@ -18,6 +18,13 @@ [Defines]
 
 [Sources]
   Dbg2Generator.c
+  Dbg2Generator.h
+
+[Sources.ARM, Sources.AARCH64]
+  Arm/ArmDbg2Generator.c
+
+[Sources.IA32, Sources.X86]
+  Common/CommonDbg2Generator.c
 
 [Packages.ARM, Packages.AARCH64]
   ArmPlatformPkg/ArmPlatformPkg.dec
diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Arm/ArmDbg2Generator.c 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Arm/ArmDbg2Generator.c
new file mode 100644
index ..a063f49829e5
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Arm/ArmDbg2Generator.c
@@ -0,0 +1,67 @@
+/** @file
+  Arm DBG2 Table Generator
+
+  Copyright (c) 2024, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.
+**/
+
+#include 
+#include 
+#include 
+#include "Dbg2Generator.h"
+
+/**
+  Initialise the serial port to the specified settings.
+  The serial port is re-configured only if the specified settings
+  are different from the current settings.
+  All unspecified settings will be set to the default values.
+
+  @param  SerialPortInfo  CM_ARCH_COMMON_SERIAL_PORT_INFO object 
describing
+  the serial port.
+  @param  BaudRateThe baud rate of the serial device. If the
+  baud rate is not supported, the speed will be
+  reduced to the nearest supported one and the
+  variable's value will be updated accordingly.
+  @param  ReceiveFifoDepthThe number of characters the device will
+  buffer on input.  Value of 0 will use the
+  device's default FIFO depth.
+  @param  Parity  If applicable, this is the EFI_PARITY_TYPE
+  that is computed or checked as each character
+  is transmitted or received. If the device
+  does not support parity, the value is the
+  default parity value.
+  @param  DataBitsThe number of data bits in each character.
+  @param  StopBitsIf applicable, the EFI_STOP_BITS_TYPE number
+  of stop bits per character.
+  If the device does not support stop bits, the
+  value is the default stop bit value.
+
+  @retval RETURN_SUCCESSAll attributes were set correctly on the
+serial device.
+  @retval RETURN_INVALID_PARAMETER  One or more of the attributes has an
+unsupported value.
+**/
+RETURN_STATUS
+EFIAPI
+Dbg2InitializePort (
+  IN  CONST CM_ARCH_COMMON_SERIAL_PORT_INFO  *SerialPortInfo,
+  IN OUT UINT64  *BaudRate,
+  IN OUT UINT32  *ReceiveFifoDepth,
+  IN OUT EFI_PARITY_TYPE *Parity,
+  IN OUT UINT8   *DataBits,
+  IN OUT EFI_STOP_BITS_TYPE  *StopBits
+  )
+{
+  return PL011UartInitializePort (
+   (UINTN)SerialPortInfo->BaseAddress,
+   SerialPortInfo->Clock,
+   BaudRate,
+   ReceiveFifoDepth,
+   Parity,
+   DataBits,
+   StopBits
+   );
+}
diff --git 
a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Common/CommonDbg2Generator.c 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Common/CommonDbg2Generator.c
new file mode 100644
index ..936f3ca46604
--- /dev/null
+++ 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Common/CommonDbg2Generator.c
@@ -0,0 +1,59 @@
+/** @file
+  Common DBG2 

[edk2-devel] [staging/dynamictables-reorg PATCH 02/15] DynamicTablesPkg: Acpi: Prepare common libraries to support other archs

2024-06-19 Thread PierreGondois
Allow other architectures to reuse ACPI common libraries by:
- Removing the Arm prefix from the BASE_NAME
- Moving Arm specific libraries/packages to ARM/AARCH64
  specific sections in the .inf files
Also remove the empty .inf sections.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 .../Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf   | 15 +++
 .../Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf   |  9 +
 .../Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf   |  9 +
 .../Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf   |  2 +-
 .../Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf   |  2 +-
 .../Library/Acpi/Common/AcpiRawLib/AcpiRawLib.inf |  9 +
 .../Acpi/Common/AcpiSpcrLib/AcpiSpcrLib.inf   |  9 +
 .../Acpi/Common/AcpiSratLib/AcpiSratLib.inf   |  2 +-
 .../AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf |  6 --
 .../Acpi/Common/AcpiSsdtPcieLib/SsdtPcieLib.inf   |  2 +-
 .../AcpiSsdtSerialPortLib/SsdtSerialPortLib.inf   |  6 --
 11 files changed, 23 insertions(+), 48 deletions(-)

diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf
index f7b7c1c025a6..32dcd20c082b 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x00010019
-  BASE_NAME  = AcpiDbg2LibArm
+  BASE_NAME  = AcpiDbg2Lib
   FILE_GUID  = A17BA4F0-3DEB-4FE5-BD27-EC008E541B22
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
@@ -19,16 +19,20 @@ [Defines]
 [Sources]
   Dbg2Generator.c
 
+[Packages.ARM, Packages.AARCH64]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
-  ArmPlatformPkg/ArmPlatformPkg.dec
   DynamicTablesPkg/DynamicTablesPkg.dec
 
+[LibraryClasses.ARM, LibraryClasses.AARCH64]
+  PL011UartLib
+
 [LibraryClasses]
   BaseLib
-  PL011UartLib
   SsdtSerialPortFixupLib
 
 [FixedPcd]
@@ -36,8 +40,3 @@ [FixedPcd]
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
-
-[Protocols]
-
-[Guids]
-
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
index 8fe34013d420..c9cd850faac0 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x00010019
-  BASE_NAME  = AcpiFadtLibArm
+  BASE_NAME  = AcpiFadtLib
   FILE_GUID  = 686FE5FE-B944-485F-8B1C-7D60E0056487
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
@@ -27,10 +27,3 @@ [Packages]
 
 [LibraryClasses]
   BaseLib
-
-[Pcd]
-
-[Protocols]
-
-[Guids]
-
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf
index 1c7f085274e6..36c343d3875a 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiMcfgLib/AcpiMcfgLib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x00010019
-  BASE_NAME  = AcpiMcfgLibArm
+  BASE_NAME  = AcpiMcfgLib
   FILE_GUID  = 8C9BDCB2-72D4-4F30-A12D-1145C3807FF7
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
@@ -27,10 +27,3 @@ [Packages]
 
 [LibraryClasses]
   BaseLib
-
-[Pcd]
-
-[Protocols]
-
-[Guids]
-
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf
index da54585c2dd9..666bdcab2225 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/AcpiPcctLib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x0001001B
-  BASE_NAME  = AcpiPcctLibArm
+  BASE_NAME  = AcpiPcctLib
   FILE_GUID  = 38FE945C-D6ED-4CD6-8D20-FCEF3260D15A
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf
index 2c7d19513d6c..a1c91a6eab74 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiPpttLib/AcpiPpttLib.inf
@@ -8,7 +8,7 @@
 
 [Defines]
   INF_VERSION= 0x0001001B
-  BASE_NAME  = AcpiPpttLibArm
+  BASE_NAME  = AcpiPpttLib
   FILE_GUID  = FA102D52-5A92-4F95-A097-1D53F9CF5959
   VERSION_STRING = 1.0
   MODULE_TYPE= DXE_DRIVER
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiRawLib/AcpiRawLib.inf 
b/DynamicTablesPkg/Library/Acpi/Common/AcpiRawLib/AcpiRawLib.inf
index f2ab1b7111fb..8b461ea05b86 100644
--- 

[edk2-devel] [staging/dynamictables-reorg PATCH 01/15] DynamicTablesPkg: Acpi: Move generic libraries to common folder

2024-06-19 Thread PierreGondois
Some of the ACPI table generators are generic enough to be re-used
by other architectures. Move the following generators to a
'Common' folder:
- AcpiDbg2Lib
- AcpiFadtLib
- AcpiMcfgLib
- AcpiPcctLib
- AcpiPpttLib
- AcpiRawLib
- AcpiSpcrLib
- AcpiSratLib
- SsdtSerialPortLib
- SsdtCpuTopologyLib
- SsdtPcieLib
and update DynamicTables.dsc.inc accordingly.

Suggested-by: Sunil V L 
Signed-off-by: Pierre Gondois 
---
 DynamicTablesPkg/DynamicTables.dsc.inc| 64 +++
 .../AcpiDbg2Lib/AcpiDbg2Lib.inf}  |  0
 .../AcpiDbg2Lib}/Dbg2Generator.c  |  0
 .../AcpiFadtLib/AcpiFadtLib.inf}  |  0
 .../AcpiFadtLib}/FadtGenerator.c  |  0
 .../AcpiMcfgLib/AcpiMcfgLib.inf}  |  0
 .../AcpiMcfgLib}/McfgGenerator.c  |  0
 .../AcpiPcctLib/AcpiPcctLib.inf}  |  0
 .../AcpiPcctLib}/PcctGenerator.c  |  0
 .../AcpiPcctLib}/PcctGenerator.h  |  0
 .../AcpiPpttLib/AcpiPpttLib.inf}  |  0
 .../AcpiPpttLib}/PpttGenerator.c  |  0
 .../AcpiPpttLib}/PpttGenerator.h  |  0
 .../AcpiRawLib/AcpiRawLib.inf}|  0
 .../AcpiRawLib}/RawGenerator.c|  0
 .../AcpiSpcrLib/AcpiSpcrLib.inf}  |  0
 .../AcpiSpcrLib}/SpcrGenerator.c  |  0
 .../AcpiSratLib/AcpiSratLib.inf}  |  0
 .../AcpiSratLib}/SratGenerator.c  |  0
 .../SsdtCpuTopologyGenerator.c|  0
 .../SsdtCpuTopologyGenerator.h|  0
 .../SsdtCpuTopologyLib.inf}   |  0
 .../AcpiSsdtPcieLib}/SsdtPcieGenerator.c  |  0
 .../AcpiSsdtPcieLib}/SsdtPcieGenerator.h  |  0
 .../AcpiSsdtPcieLib/SsdtPcieLib.inf}  |  0
 .../SsdtSerialPortGenerator.c |  0
 .../SsdtSerialPortLib.inf}|  0
 27 files changed, 38 insertions(+), 26 deletions(-)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf => 
Common/AcpiDbg2Lib/AcpiDbg2Lib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiDbg2LibArm => 
Common/AcpiDbg2Lib}/Dbg2Generator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf => 
Common/AcpiFadtLib/AcpiFadtLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiFadtLibArm => 
Common/AcpiFadtLib}/FadtGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf => 
Common/AcpiMcfgLib/AcpiMcfgLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiMcfgLibArm => 
Common/AcpiMcfgLib}/McfgGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPcctLibArm/AcpiPcctLibArm.inf => 
Common/AcpiPcctLib/AcpiPcctLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPcctLibArm => 
Common/AcpiPcctLib}/PcctGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPcctLibArm => 
Common/AcpiPcctLib}/PcctGenerator.h (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPpttLibArm/AcpiPpttLibArm.inf => 
Common/AcpiPpttLib/AcpiPpttLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPpttLibArm => 
Common/AcpiPpttLib}/PpttGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiPpttLibArm => 
Common/AcpiPpttLib}/PpttGenerator.h (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiRawLibArm/AcpiRawLibArm.inf => 
Common/AcpiRawLib/AcpiRawLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiRawLibArm => 
Common/AcpiRawLib}/RawGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf => 
Common/AcpiSpcrLib/AcpiSpcrLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSpcrLibArm => 
Common/AcpiSpcrLib}/SpcrGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSratLibArm/AcpiSratLibArm.inf => 
Common/AcpiSratLib/AcpiSratLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSratLibArm => 
Common/AcpiSratLib}/SratGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtCpuTopologyLibArm => 
Common/AcpiSsdtCpuTopologyLib}/SsdtCpuTopologyGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtCpuTopologyLibArm => 
Common/AcpiSsdtCpuTopologyLib}/SsdtCpuTopologyGenerator.h (100%)
 rename 
DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyLibArm.inf
 => Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtPcieLibArm => 
Common/AcpiSsdtPcieLib}/SsdtPcieGenerator.c (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtPcieLibArm => 
Common/AcpiSsdtPcieLib}/SsdtPcieGenerator.h (100%)
 rename 
DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf => 
Common/AcpiSsdtPcieLib/SsdtPcieLib.inf} (100%)
 rename DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtSerialPortLibArm => 
Common/AcpiSsdtSerialPortLib}/SsdtSerialPortGenerator.c (100%)
 rename 
DynamicTablesPkg/Library/Acpi/{Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortLibArm.inf
 => 

[edk2-devel] [staging/dynamictables-reorg PATCH 00/15] Prepare libraries to support other archs

2024-06-19 Thread PierreGondois
The DynamicTables framework has mainly been developed/tested against Arm
architecture. While still trying to have re-usable libraries, opening the
framework to other architectures implies some re-organization.

The libraries that are generic enough to be directly re-used are moved
to a Common/ directory. For some libraries, additional arch-specific hooks
have been added to allow architectures specific modifications.

---

Changes can be seen at:
  https://github.com/pierregondois/edk2/tree/pg/dyntables_libraries_reorg

---

References:
1. Staging branch creation:
   URL: https://edk2.groups.io/g/devel/message/114790

2. edk2-staging Repo
   URL: https://github.com/tianocore/edk2-staging.git
   Branch Name: dynamictables-reorg

3. edk2-platforms Repo
   URL: https://github.com/tianocore/edk2-platforms.git
   Branch Name: devel-dynamictables-reorg

---

Cc: AbdulLateef Attar 
Cc: Girish Mahadevan 
Cc: Jeff Brasen 
Cc: Jeshua Smith 
Cc: Leif Lindholm 
Cc: Meenakshi Aggarwal 
Cc: Pierre Gondois 
Cc: Sami Mujawar 
Cc: Sunil V L 
Cc: Yeo Reum Yun 

Pierre Gondois (15):
  DynamicTablesPkg: Acpi: Move generic libraries to common folder
  DynamicTablesPkg: Acpi: Prepare common libraries to support other
archs
  DynamicTablesPkg: AcpiFadtLib: Prepare to support other archs
  DynamicTablesPkg: AcpiDbg2Lib: Prepare to support other archs
  DynamicTablesPkg: AcpiSpcrLib: Prepare to support other archs
  DynamicTablesPkg: AcpiSratLib: Prepare to support other archs
  DynamicTablesPkg: AcpiSsdtCpuTopologyLib: Avoid dependency on GICC
  DynamicTablesPkg: DynamicTableManagerDxe: Refactor PresenceArray
  DynamicTablesPkg: FdtHwInfoParserLib: Move ARM parsers to Arm
directory
  DynamicTablesPkg: FdtHwInfoParserLib: Refactor to prepare for other
archs
  DynamicTablesPkg: FdtHwInfoParserLib: Make Pci parser arch neutral
  DynamicTablesPkg: FdtHwInfoParserLib: Make Serial Port parser arch
neutral
  DynamicTablesPkg: FdtHwInfoParserLib: Move ArmLib.h to ArmGicCParser.c
  DynamicTablesPkg: FdtHwInfoParserLib: Move IRQ map to arch folder
  DynamicTablesPkg: FdtHwInfoParserLib: Create wrapper to get INTC addr
cells

 .../Arm/ArmDynamicTableManagerDxe.c   |  63 +++
 .../Common/CommonDynamicTableManagerDxe.c |  58 +++
 .../DynamicTableManagerDxe.c  |  70 +--
 .../DynamicTableManagerDxe.h  |  63 +++
 .../DynamicTableManagerDxe.inf|   7 +
 DynamicTablesPkg/DynamicTables.dsc.inc|  64 +--
 .../SsdtCpuTopologyGenerator.h| 147 ---
 .../AcpiDbg2Lib/AcpiDbg2Lib.inf}  |  22 +-
 .../Common/AcpiDbg2Lib/Arm/ArmDbg2Generator.c |  67 +++
 .../AcpiDbg2Lib/Common/CommonDbg2Generator.c  |  59 +++
 .../AcpiDbg2Lib}/Dbg2Generator.c  |  24 +-
 .../Acpi/Common/AcpiDbg2Lib/Dbg2Generator.h   |  56 +++
 .../AcpiFadtLib/AcpiFadtLib.inf}  |  16 +-
 .../Common/AcpiFadtLib/Arm/ArmFadtGenerator.c | 126 ++
 .../AcpiFadtLib/Common/CommonFadtGenerator.c  |  46 ++
 .../AcpiFadtLib}/FadtGenerator.c  |  86 +---
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.h   |  35 ++
 .../AcpiMcfgLib/AcpiMcfgLib.inf}  |   9 +-
 .../AcpiMcfgLib}/McfgGenerator.c  |   0
 .../AcpiPcctLib/AcpiPcctLib.inf}  |   2 +-
 .../AcpiPcctLib}/PcctGenerator.c  |   0
 .../AcpiPcctLib}/PcctGenerator.h  |   0
 .../AcpiPpttLib/AcpiPpttLib.inf}  |   2 +-
 .../AcpiPpttLib}/PpttGenerator.c  |   0
 .../AcpiPpttLib}/PpttGenerator.h  |   0
 .../AcpiRawLib/AcpiRawLib.inf}|   9 +-
 .../AcpiRawLib}/RawGenerator.c|   0
 .../AcpiSpcrLib/AcpiSpcrLib.inf}  |   9 +-
 .../AcpiSpcrLib}/SpcrGenerator.c  |   2 +-
 .../AcpiSratLib/AcpiSratLib.inf}  |   9 +-
 .../Common/AcpiSratLib/Arm/ArmSratGenerator.c | 262 +++
 .../AcpiSratLib/Common/CommonSratGenerator.c  |  77 
 .../AcpiSratLib}/SratGenerator.c  | 214 +
 .../Acpi/Common/AcpiSratLib/SratGenerator.h   |  59 +++
 .../Arm/ArmSsdtCpuTopologyGenerator.c | 408 ++
 .../SsdtCpuTopologyGenerator.c| 341 ++-
 .../SsdtCpuTopologyGenerator.h| 343 +++
 .../SsdtCpuTopologyLib.inf}   |   9 +-
 .../AcpiSsdtPcieLib}/SsdtPcieGenerator.c  |   2 +-
 .../AcpiSsdtPcieLib}/SsdtPcieGenerator.h  |   0
 .../AcpiSsdtPcieLib/SsdtPcieLib.inf}  |   2 +-
 .../SsdtSerialPortGenerator.c |   0
 .../SsdtSerialPortLib.inf}|   6 +-
 .../Arm/ArmFdtHwInfoParser.c  |  83 
 .../FdtHwInfoParserLib/Arm/ArmFdtUtility.c| 118 +
 .../{ => Arm}/BootArch/ArmBootArchParser.c|   2 +-
 .../{ => Arm}/BootArch/ArmBootArchParser.h|   0
 .../GenericTimer/ArmGenericTimerParser.c  |   4 +-
 .../GenericTimer/ArmGenericTimerParser.h  |   0
 .../{ => Arm}/Gic/ArmGicCParser.c |   5 

[edk2-devel] [edk2-libc Patch 0/1] update build and packaging scripts to take EDK2_LIBC_PATH

2024-06-19 Thread Jayaprakash, N
This commit adds necessary changes to build and packaging scripts
to take path to edk2-libc through an environment variable.
It also updates the build and packaging instructions in
GCCCompilationBKMs.rst file and Py368ReadMe.txt files.
The Python368.inf file is also updated to take EDK2_LIBC_PATH
instead of the current WORKSPACE path in the CC flags.
Please refer to BZ4791 for more details.

Jayaprakash N (1):
  edk2-libc : update build and packaging scripts to take EDK2_LIBC_PATH

 .../Python-3.6.8/GCCCompilationBKMs.rst   | 21 +++--
 .../Python/Python-3.6.8/Py368ReadMe.txt   | 22 --
 .../Python/Python-3.6.8/Python368.inf |  6 ++---
 .../Python/Python-3.6.8/create_python_pkg.bat | 21 ++---
 .../Python/Python-3.6.8/create_python_pkg.sh  | 23 ---
 5 files changed, 75 insertions(+), 18 deletions(-)

-- 
2.45.1.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc : update build and packaging scripts to take EDK2_LIBC_PATH

2024-06-19 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4791

This commit adds necessary changes to build and packaging scripts
to take path to edk2-libc through an environment variable.
It also updates the build and packaging instructions in
GCCCompilationBKMs.rst file and Py368ReadMe.txt files.
The Python368.inf file is also updated to take EDK2_LIBC_PATH
instead of the current WORKSPACE path in the CC flags.

Cc: Rebecca Cran 
Cc: Michael D Kinney 
Cc: Jayaprakash N 
Signed-off-by: Jayaprakash N 
---
 .../Python-3.6.8/GCCCompilationBKMs.rst   | 21 +++--
 .../Python/Python-3.6.8/Py368ReadMe.txt   | 22 --
 .../Python/Python-3.6.8/Python368.inf |  6 ++---
 .../Python/Python-3.6.8/create_python_pkg.bat | 21 ++---
 .../Python/Python-3.6.8/create_python_pkg.sh  | 23 ---
 5 files changed, 75 insertions(+), 18 deletions(-)

diff --git a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst 
b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
index 0574977..667b408 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
+++ b/AppPkg/Applications/Python/Python-3.6.8/GCCCompilationBKMs.rst
@@ -136,17 +136,17 @@ Now clone the edk2-libc git repo by following / executing 
the below commands::
 
 bash$ cd ~/src
 bash$ git clone https://github.com/tianocore/edk2-libc.git
-bash$ export PACKAGES_PATH=$HOME/src/edk2:$HOME/src/edk2-libc
 
+Set the PACKAGES_PATH and EDK2_LIBC_PATH using the commands below::
+
+bash$ export PACKAGES_PATH=$HOME/src/edk2:$HOME/src/edk2-libc
+bash$ export EDK2_LIBC_PATH=$HOME/src/edk2-libc
 
 Verify that you can build the hello world application from AppPkg under 
edk2-libc by running the following commands
 Build hello.inf from edk2-libc applications::
 
-$bash build -p AppPkg/AppPkg.dsc -m AppPkg/Applications/Hello/Hello.inf
-
-Copy the contents of edk2-libc to edk2 folder::
+$bash build -p ../edk2-libc/AppPkg/AppPkg.dsc -m 
../edk2-libc/AppPkg/Applications/Hello/Hello.inf
 
-bash$ cp -rf ~/src/edk2-libc/* ~/src/edk2/
 
 2.5.  Build Python Interpreter using GCC
 
@@ -156,7 +156,8 @@ Execute the below command to build the X64 version of the 
Python 3.6.8 interpret
 bash$ cd AppPkg/Applications/Python/Python-3.6.8/
 bash$ python srcprep.py
 bash$ cd ~/src/edk2
-bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -m 
AppPkg/Applications/Python/Python-3.6.8/Python368.inf -D BUILD_PYTHON368
+bash$ build -a X64 -b RELEASE -p ../edk2-libc/AppPkg/AppPkg.dsc \
+  -m 
../edk2-libc/AppPkg/Applications/Python/Python-3.6.8/Python368.inf -D 
BUILD_PYTHON368
  or
 bash$ build -a X64 -b RELEASE -p AppPkg/AppPkg.dsc -D BUILD_PYTHON368
 
@@ -166,7 +167,13 @@ Execute the below command to build the X64 version of the 
Python 3.6.8 interpret
 
 To create an usable Python UEFI package with all the dependencies from the 
build environment,
 you can use the bash shell script create_python_pkg.sh available under 
/AppPkg/Applications/Python/Python-3.6.8
-folder.
+folder. Ensure that EDK2_LIBC_PATH environment variable to edk2-libc folder 
path.
+
+Ensure that EDK2_LIBC_PATH environment variable to edk2-libc folder path::
+
+bash$ echo $EDK2_LIBC_PATH
+
+The environment variable should be set to the folder path for the edk2-libc 
cloned repo.
 
 Use the following commands to create Python UEFI package::
 
diff --git a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt 
b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
index 91f4c24..8a0b3fe 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
+++ b/AppPkg/Applications/Python/Python-3.6.8/Py368ReadMe.txt
@@ -68,7 +68,24 @@ and that you can successfully build packages within that 
distribution.
 gc  itertools   math  _operator
 time
 
-  C.  Build AppPkg using the standard "build" command:
+  C.  Set the PACKAGES_PATH and EDK2_LIBC_PATH environment variables to
+the right values. PACKAGES_PATH should be set to the folder path of
+edk2 and edk2-libc folders. EDK2_LIBC_PATH should be set to the
+folder path of edk2-libc.
+Use the below provided commands as reference to set the environment
+variables to the corresponding values
+
+set PACKAGES_PATH=;;
+   set EDK2_LIBC_PATH=
+
+where,
+ should be replaced with the absolute path to
+   edk2 folder on your development system.
+
+ should be replaced with the absolute path
+   to edk2-libc folder on your development system.
+
+  D.  Build AppPkg using the standard "build" command:
 For example, to build Python for an X64 CPU architecture:
 build -a X64 -p AppPkg\AppPkg.dsc -D BUILD_PYTHON368
 
@@ -115,7 +132,8 @@ system as follows:
   A script, 

[edk2-devel] [Question] What is the propose of BME DMA mitigation

2024-06-19 Thread memristor2 via groups.io
Hello everyone,
I was scrolling through the UEFI HII and encountered an option which i failed 
to find any proper explanation about it.
Could you please explain point of mitigating DMA access for PCI.Thanks

--- Forwarded Message ---
From: memristor2 
Date: On Tuesday, June 18th, 2024 at 4:56 PM
Subject: [Question] What is the propose of BME DMA mitigation
To: disc...@edk2.groups.io 

> Hello everyone,
> I was scrolling through the UEFI HII and encountered an option which i failed 
> to find any proper explanation about it.
> Could you please explain point of mitigating DMA access for PCI.
> Thanks

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119629): https://edk2.groups.io/g/devel/message/119629
Mute This Topic: https://groups.io/mt/106756522/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 1/1] QemuSbsa: enable WriteCombine for the FrameBuffer

2024-06-19 Thread Marcin Juszkiewicz

W dniu 19.06.2024 o 09:09, Ard Biesheuvel pisze:

On Wed, 19 Jun 2024 at 07:52, Marcin Juszkiewicz
  wrote:

QEMU no longer permits misaligned access to device memory, which breaks
QemuVideoDxe on SbsaQemu.

c1d1910be6e04a8b1a73090cf2881fb698947a6e commit in EDK2 fixed it by
enabling WriteCombine for Framebuffer memory. This change enables that
fix.

Signed-off-by: Marcin Juszkiewicz

Reviewed-by: Ard Biesheuvel


Thanks. Pushed as 3f08401365d67e10924c774e6c3f64be56bc15b6.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119628): https://edk2.groups.io/g/devel/message/119628
Mute This Topic: https://groups.io/mt/106755714/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 1/1] QemuSbsa: enable WriteCombine for the FrameBuffer

2024-06-19 Thread Ard Biesheuvel
On Wed, 19 Jun 2024 at 07:52, Marcin Juszkiewicz
 wrote:
>
> QEMU no longer permits misaligned access to device memory, which breaks
> QemuVideoDxe on SbsaQemu.
>
> c1d1910be6e04a8b1a73090cf2881fb698947a6e commit in EDK2 fixed it by
> enabling WriteCombine for Framebuffer memory. This change enables that
> fix.
>
> Signed-off-by: Marcin Juszkiewicz 

Reviewed-by: Ard Biesheuvel 

> ---
>  Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc 
> b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
> index b012eaa34147..11126bcaa1fe 100644
> --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
> +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
> @@ -311,6 +311,9 @@ [PcdsFeatureFlag.common]
>gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
>gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
>
> +  # Enable WriteCombine for FrameBuffer
> +  gUefiOvmfPkgTokenSpaceGuid.PcdRemapFrameBufferWriteCombine|TRUE
> +
>  [PcdsFixedAtBuild.common]
>gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|100
>gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|100
> --
> 2.45.1
>
>
>
> 
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#119626): https://edk2.groups.io/g/devel/message/119626
> Mute This Topic: https://groups.io/mt/106755714/5717338
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [ardb+tianoc...@kernel.org]
> 
>
>


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