* Use ACPI 5.1 everywhere, since we are constrained to use v5.x for
  MADT compatibility.
* Clean up whitespaces and reorganize header declaration.
* Prefix all RPi related constant with RPI_ to make them clearer to
  differentiate from regular EDK2 ones.
* Reference IndustryStandard/Acpi.h always.
* Remove explicit references to RPI4 for sources that we may be
  factorized for both the Pi 3 and Pi 4 platform.

Signed-off-by: Pete Batard <p...@akeo.ie>
---
 Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h | 12 +++---
 Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc    | 42 ++++++++++----------
 Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc    | 30 +++++++-------
 Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc    | 11 ++---
 Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl      |  4 +-
 Platform/RaspberryPi/RPi4/AcpiTables/Pep.c        |  6 +--
 Platform/RaspberryPi/RPi4/AcpiTables/Pep.h        |  8 ++--
 7 files changed, 58 insertions(+), 55 deletions(-)

diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h 
b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
index e61f3fa0bcfa..dcdbac7a0b7b 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
@@ -13,7 +13,7 @@
 #ifndef __ACPITABLES_H__
 #define __ACPITABLES_H__
 
-#include <IndustryStandard/Acpi50.h>
+#include <IndustryStandard/Acpi.h>
 
 #define EFI_ACPI_OEM_ID                       {'M','C','R','S','F','T'} // 
OEMID 6 bytes long
 #define EFI_ACPI_OEM_TABLE_ID                 SIGNATURE_64 
('R','P','I','4','E','D','K','2') // OEM table id 8 bytes long
@@ -41,10 +41,10 @@
 #define EFI_ACPI_CSRT_DEVICE_ID_DMA           0x00000009 // Fixed id
 #define EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP  0x0 // Count up from 0
 
-#define RPI4_DMA_CHANNEL_COUNT                10 // All 10 DMA channels are 
listed, including the reserved ones
-#define RPI4_DMA_USED_CHANNEL_COUNT           5  // Use 5 DMA channels
+#define RPI_DMA_CHANNEL_COUNT                 10 // All 10 DMA channels are 
listed, including the reserved ones
+#define RPI_DMA_USED_CHANNEL_COUNT            5  // Use 5 DMA channels
 
-#define EFI_ACPI_5_0_CSRT_REVISION            0x00000000
+#define EFI_ACPI_5_1_CSRT_REVISION            0x00000000
 
 typedef enum
 {
@@ -76,7 +76,7 @@ typedef struct
   UINT16 Revision;                // 2 bytes
   UINT16 Reserved;                // 2 bytes
   UINT32 SharedInfoLength;        // 4 bytes
-} EFI_ACPI_5_0_CSRT_RESOURCE_GROUP_HEADER;
+} EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER;
 
 //------------------------------------------------------------------------
 // CSRT Resource Descriptor 12 bytes total
@@ -87,6 +87,6 @@ typedef struct
   UINT16 ResourceType;            // 2 bytes
   UINT16 ResourceSubType;         // 2 bytes
   UINT32 UID;                     // 4 bytes
-} EFI_ACPI_5_0_CSRT_RESOURCE_DESCRIPTOR_HEADER;
+} EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER;
 
 #endif // __ACPITABLES_H__
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc 
b/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc
index 22a370d04017..f8bf3f26a341 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc
@@ -9,14 +9,16 @@
  *
  **/
 
+#include <IndustryStandard/Acpi.h>
+
 #include "AcpiTables.h"
 
-#define DMA_MAX_REQ_LINES 32
+#define RPI_DMA_MAX_REQ_LINES 32
 
 #pragma pack (push, 1)
 
 //------------------------------------------------------------------------
-// DMA Controller Vendor Data for RPi4
+// DMA Controller Vendor Data
 //------------------------------------------------------------------------
 typedef struct
 {
@@ -34,16 +36,16 @@ typedef struct
 } DMA_CONTROLLER_VENDOR_DATA;
 
 //------------------------------------------------------------------------
-// DMA Controller on RPi4
+// DMA Controller
 //------------------------------------------------------------------------
 typedef struct
 {
-  EFI_ACPI_5_0_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaControllerHeader;
+  EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaControllerHeader;
   DMA_CONTROLLER_VENDOR_DATA ControllerVendorData;
 } RD_DMA_CONTROLLER;
 
 //------------------------------------------------------------------------
-// DMA Channel Vendor Data for RPi4
+// DMA Channel Vendor Data
 //------------------------------------------------------------------------
 typedef struct
 {
@@ -54,27 +56,27 @@ typedef struct
 } DMA_CHANNEL_VENDOR_DATA;
 
 //------------------------------------------------------------------------
-// DMA Channel on RPi4
+// DMA Channel
 //------------------------------------------------------------------------
 typedef struct
 {
-  EFI_ACPI_5_0_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaChannelHeader;
+  EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaChannelHeader;
   DMA_CHANNEL_VENDOR_DATA ChannelVendorData;
 } RD_DMA_CHANNEL;
 
 //------------------------------------------------------------------------
-// DMA Resource Group on RPi4
+// DMA Resource Group
 //------------------------------------------------------------------------
 
 typedef struct
 {
-  EFI_ACPI_5_0_CSRT_RESOURCE_GROUP_HEADER ResGroupHeader;
+  EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER ResGroupHeader;
   RD_DMA_CONTROLLER DmaController;
-  RD_DMA_CHANNEL DmaChannels[RPI4_DMA_CHANNEL_COUNT];
+  RD_DMA_CHANNEL DmaChannels[RPI_DMA_CHANNEL_COUNT];
 } RG_DMA;
 
 //----------------------------------------------------------------------------
-// CSRT table structure for RPi4 platform - current revision only includes DMA
+// CSRT table structure - current revision only includes DMA
 //----------------------------------------------------------------------------
 typedef struct
 {
@@ -84,20 +86,20 @@ typedef struct
 // DMA Resource Group
   RG_DMA DmaResourceGroup;
 
-} EFI_ACPI_5_0_CSRT_TABLE;
+} EFI_ACPI_5_1_CSRT_TABLE;
 
-EFI_ACPI_5_0_CSRT_TABLE Csrt =
+EFI_ACPI_5_1_CSRT_TABLE Csrt =
 {
   //------------------------------------------------------------------------
   // ACPI Table Header
   //------------------------------------------------------------------------
   {
-    EFI_ACPI_5_0_CORE_SYSTEM_RESOURCE_TABLE_SIGNATURE,       // Signature 
"CSRT"
+    EFI_ACPI_5_1_CORE_SYSTEM_RESOURCE_TABLE_SIGNATURE,       // Signature 
"CSRT"
     sizeof (EFI_ACPI_DESCRIPTION_HEADER) + sizeof (RG_DMA),  // Length
-    EFI_ACPI_5_0_CSRT_REVISION,     // Revision
+    EFI_ACPI_5_1_CSRT_REVISION,     // Revision
     0x00,                           // Checksum calculated at runtime.
-    EFI_ACPI_OEM_ID,                // OEMID is a 6 bytes long field "BC2836"
-    EFI_ACPI_OEM_TABLE_ID,          // OEM table identification(8 bytes long) 
"RPI4EDK2"
+    EFI_ACPI_OEM_ID,                // OEMID is a 6 bytes long field
+    EFI_ACPI_OEM_TABLE_ID,          // OEM table identification (8 bytes long)
     EFI_ACPI_OEM_REVISION,          // OEM revision number.
     EFI_ACPI_CREATOR_ID,            // ASL compiler vendor ID.
     EFI_ACPI_CREATOR_REVISION       // ASL compiler revision number.
@@ -136,13 +138,13 @@ EFI_ACPI_5_0_CSRT_TABLE Csrt =
         sizeof (DMA_CONTROLLER_VENDOR_DATA),  // Controller vendor data here
         1,
         0xFE007000,                   // Base address for channels
-        RPI4_DMA_CHANNEL_COUNT * 0x100, // Base size = Number of channels x 
0x100 size for each channel
+        RPI_DMA_CHANNEL_COUNT * 0x100, // Base size = Number of channels x 
0x100 size for each channel
         0xFE007FE0,                   // Base address for controller
         8,                            // Base size = two registers
-        RPI4_DMA_USED_CHANNEL_COUNT,
+        RPI_DMA_USED_CHANNEL_COUNT,
         0,                            // cannot use controller interrupt
         0,                            // Minimum Request Line
-        DMA_MAX_REQ_LINES - 1,          // Maximum Request Line
+        RPI_DMA_MAX_REQ_LINES - 1,    // Maximum Request Line
         FALSE,
       },
     },
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc 
b/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc
index 293c6022d258..7c2aa9389456 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc
@@ -8,41 +8,41 @@
 *
 **/
 
+#include <IndustryStandard/Acpi.h>
 #include <Library/AcpiLib.h>
 #include <Library/PcdLib.h>
-#include <IndustryStandard/Acpi.h>
 
 #include "AcpiTables.h"
 
-#define SYSTEM_TIMER_BASE_ADDRESS   0xFF80001C
-#define GTDT_GLOBAL_FLAGS           0
-#define GTDT_GTIMER_FLAGS           
EFI_ACPI_6_0_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
+#define RPI_SYSTEM_TIMER_BASE_ADDRESS   0xFF80001C
+#define RPI_GTDT_GLOBAL_FLAGS           0
+#define RPI_GTDT_GTIMER_FLAGS           
EFI_ACPI_5_1_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
 
 #pragma pack (1)
 
 typedef struct {
-  EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt;
-} EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLES;
+  EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt;
+} EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES;
 
 #pragma pack ()
 
-EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = {
+EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = {
   {
     ACPI_HEADER(
-      EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
-      EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLES,
-      EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION
+      EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
+      EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES,
+      EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION
     ),
-    SYSTEM_TIMER_BASE_ADDRESS,                    // UINT64  PhysicalAddress
+    RPI_SYSTEM_TIMER_BASE_ADDRESS,                // UINT64  PhysicalAddress
     0,                                            // UINT32  Reserved
     FixedPcdGet32 (PcdArmArchTimerSecIntrNum),    // UINT32  SecurePL1TimerGSIV
-    GTDT_GTIMER_FLAGS,                            // UINT32  
SecurePL1TimerFlags
+    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  
SecurePL1TimerFlags
     FixedPcdGet32 (PcdArmArchTimerIntrNum),       // UINT32  
NonSecurePL1TimerGSIV
-    GTDT_GTIMER_FLAGS,                            // UINT32  
NonSecurePL1TimerFlags
+    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  
NonSecurePL1TimerFlags
     FixedPcdGet32 (PcdArmArchTimerVirtIntrNum),   // UINT32  VirtualTimerGSIV
-    GTDT_GTIMER_FLAGS,                            // UINT32  VirtualTimerFlags
+    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  VirtualTimerFlags
     FixedPcdGet32 (PcdArmArchTimerHypIntrNum),    // UINT32  
NonSecurePL2TimerGSIV
-    GTDT_GTIMER_FLAGS,                            // UINT32  
NonSecurePL2TimerFlags
+    RPI_GTDT_GTIMER_FLAGS,                        // UINT32  
NonSecurePL2TimerFlags
     0xFFFFFFFFFFFFFFFF,                           // UINT64  
CntReadBasePhysicalAddress
     0,                                            // UINT32  PlatformTimerCount
     0                                             // UINT32 PlatfromTimerOffset
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc 
b/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc
index 0027cb9fe8bb..f847a9310ff7 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc
@@ -8,11 +8,12 @@
 *
 **/
 
-#include "AcpiTables.h"
+#include <IndustryStandard/Acpi.h>
 #include <Library/AcpiLib.h>
 #include <Library/ArmLib.h>
 #include <Library/PcdLib.h>
-#include <IndustryStandard/Acpi51.h>
+
+#include "AcpiTables.h"
 
 //
 // Multiple APIC Description Table
@@ -45,13 +46,13 @@ PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
         0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 48, FixedPcdGet64 
(PcdGicInterruptInterfaceBase),
         0xFF846000, 0xFF844000, 0x19, 0),
     EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        1, 1, GET_MPID(0, 1),  EFI_ACPI_5_1_GIC_ENABLED, 49, FixedPcdGet64 
(PcdGicInterruptInterfaceBase),
+        1, 1, GET_MPID(0, 1), EFI_ACPI_5_1_GIC_ENABLED, 49, FixedPcdGet64 
(PcdGicInterruptInterfaceBase),
         0xFF846000, 0xFF844000, 0x19, 0),
     EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        2, 2, GET_MPID(0, 2),  EFI_ACPI_5_1_GIC_ENABLED, 50, FixedPcdGet64 
(PcdGicInterruptInterfaceBase),
+        2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 50, FixedPcdGet64 
(PcdGicInterruptInterfaceBase),
         0xFF846000, 0xFF844000, 0x19, 0),
     EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
-        3, 3, GET_MPID(0, 3),  EFI_ACPI_5_1_GIC_ENABLED, 51, FixedPcdGet64 
(PcdGicInterruptInterfaceBase),
+        3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 51, FixedPcdGet64 
(PcdGicInterruptInterfaceBase),
         0xFF846000, 0xFF844000, 0x19, 0),
   },
   EFI_ACPI_5_0_GIC_DISTRIBUTOR_INIT(0, FixedPcdGet64 (PcdGicDistributorBase), 
0)
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl 
b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl
index 7096109f8819..8a0a44e1c4c9 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl
@@ -13,9 +13,9 @@
 Device(PEPD)
 {
   //
-  // RPI4 PEP virtual device.
+  // PEP virtual device.
   //
-  Name (_HID, "BCM2854") // Note: since pep on rpi4 is virtual device,
+  Name (_HID, "BCM2854") // Note: Since PEP on RPi is a virtual device,
   Name (_CID, "BCM2854") // its device id needs to be generated by Microsoft
   Name (_UID, 0x0)
   Name (_CRS, ResourceTemplate ()
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c 
b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c
index 1a78392f05a0..f452580c703d 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c
@@ -12,7 +12,7 @@
 
 #include "Pep.h"
 
-PEP_PROCESSOR_TABLE_PLAT RPI4Processors = {
+PEP_PROCESSOR_TABLE_PLAT RpiProcessors = {
   1, // Version
   1, // NumberProcessors
   {  // ProcessorInfo
@@ -30,7 +30,7 @@ PEP_PROCESSOR_TABLE_PLAT RPI4Processors = {
   }
 };
 
-PEP_COORDINATED_STATE_TABLE_PLAT RPI4CoordinatedStates = {
+PEP_COORDINATED_STATE_TABLE_PLAT RpiCoordinatedStates = {
   1, // Version
   1, // CoordinatedStateCount
   { // CordinatedStates[]
@@ -52,7 +52,7 @@ PEP_COORDINATED_STATE_TABLE_PLAT RPI4CoordinatedStates = {
   }
 };
 
-PEP_DEVICE_TABLE_PLAT RPI4Devices = {
+PEP_DEVICE_TABLE_PLAT RpiDevices = {
   1, // Version
   1, // NumberDevices
   { // DeviceInfo
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h 
b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h
index 19b801caf783..30f6768f12a5 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h
@@ -14,10 +14,10 @@
  * Note: Not everything is here. At least SOC_STATE_TYPE is missing.
  */
 
-#ifndef _RPI4PEP_H_INCLUDED_
-#define _RPI4PEP_H_INCLUDED_
+#ifndef _RPI_PEP_H_INCLUDED_
+#define _RPI_PEP_H_INCLUDED_
 
-#include <IndustryStandard/Acpi50.h>
+#include <IndustryStandard/Acpi.h>
 
 #define PEP_MAX_DEPENDENCIES_PER_STATE 16
 #define MAX_PROCESSOR_PATH_LENGTH 16
@@ -118,4 +118,4 @@ typedef struct _PEP_DEVICE_TABLE_PLAT {
   PEP_DEVICE_INFO_PLAT DeviceInfo[P_NUMBER_DEVICES];
 } PEP_DEVICE_TABLE_PLAT, *PPEP_DEVICE_TABLE_PLAT;
 
-#endif // _RPI4PEP_H_INCLUDED_
+#endif // _RPI_PEP_H_INCLUDED_
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52407): https://edk2.groups.io/g/devel/message/52407
Mute This Topic: https://groups.io/mt/68829923/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to