Use code derived from JunoPkg to generate our serial tables and
also use PCDs where possible.
Signed-off-by: Pete Batard <p...@akeo.ie>
---
Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf | 4 +-
Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc | 100 +++++++++++++++++---
Platform/RaspberryPi/RPi4/AcpiTables/Spcr.asl | 48 ----------
Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc | 94 ++++++++++++++++++
4 files changed, 183 insertions(+), 63 deletions(-)
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
index 50c9f7694d84..6b1155d66444 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
@@ -31,7 +31,7 @@ [Sources]
Gtdt.aslc
Dsdt.asl
Csrt.aslc
- Spcr.asl
+ Spcr.aslc
[Packages]
ArmPkg/ArmPkg.dec
@@ -47,4 +47,6 @@ [FixedPcd]
gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
gArmTokenSpaceGuid.PcdGicDistributorBase
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
index 849cf5134793..589a5c2cbd71 100644
--- a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
+++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
@@ -2,27 +2,99 @@
*
* Debug Port Table (DBG2)
*
- * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Copyright (c) 2019, Pete Batard <p...@akeo.ie>
+ * Copyright (c) 2012-2016, ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
**/
-UINT8 Dbg2[92] = {
- 0x44, 0x42, 0x47, 0x32, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x4D, 0x53, 0x46, 0x54, 0x20, 0x20, 0x45, 0x44, 0x4B, 0x32,
- 0x20, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x00, 0x4D, 0x53,
- 0x46, 0x54, 0x01, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x01, 0x0A, 0x00,
- 0x26, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x80, 0x10, 0x00,
- 0x00, 0x00, 0x16, 0x00, 0x22, 0x00, 0x00, 0x20, 0x00, 0x10,
- 0x00, 0x50, 0x21, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00,
- 0x00, 0x00, '\\', '_', 'S', 'B', '.', 'U', 'R', 'T',
- 'M', 0x00,
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/DebugPort2Table.h>
+#include <Library/AcpiLib.h>
+#include <Library/PcdLib.h>
+
+#include "AcpiTables.h"
+
+#pragma pack(1)
+
+#define RPI_DBG2_NUM_DEBUG_PORTS 1
+#define RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS 1
+#define RPI_DBG2_NAMESPACESTRING_FIELD_SIZE 10
+
+//
+// When using the miniUART, PcdSerialRegisterBase points to the 8250 base
address,
+// which is offset by 0x40 from the actual Bcm2835 base address
+//
+#define RPI_UART_BASE_ADDRESS (FixedPcdGet64
(PcdSerialRegisterBase) - 0x40)
+#define RPI_UART_LENGTH 0x70
+//
+// RPI_UART_STR should match the value used Uart.asl
+//
+#define RPI_UART_STR { '\\', '_', 'S', 'B',
'.', 'U', 'R', 'T', 'M', 0x00 }
+
+typedef struct {
+ EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT Dbg2Device;
+ EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister;
+ UINT32 AddressSize;
+ UINT8
NameSpaceString[RPI_DBG2_NAMESPACESTRING_FIELD_SIZE];
+} DBG2_DEBUG_DEVICE_INFORMATION;
+
+typedef struct {
+ EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE Description;
+ DBG2_DEBUG_DEVICE_INFORMATION
Dbg2DeviceInfo[RPI_DBG2_NUM_DEBUG_PORTS];
+} DBG2_TABLE;
+
+
+#define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen,
UartNameStr) { \
+ {
\
+ EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, /* UINT8
Revision */ \
+ sizeof (DBG2_DEBUG_DEVICE_INFORMATION), /*
UINT16 Length */ \
+ NumReg, /* UINT8
NumberofGenericAddressRegisters */ \
+ RPI_DBG2_NAMESPACESTRING_FIELD_SIZE, /*
UINT16 NameSpaceStringLength */ \
+ OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString), /*
UINT16 NameSpaceStringOffset */ \
+ 0, /*
UINT16 OemDataLength */ \
+ 0, /*
UINT16 OemDataOffset */ \
+ EFI_ACPI_DBG2_PORT_TYPE_SERIAL, /*
UINT16 Port Type */ \
+ SubType, /*
UINT16 Port Subtype */ \
+ {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}, /* UINT8
Reserved[2] */ \
+ OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), /*
UINT16 BaseAddressRegister Offset */ \
+ OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize) /*
UINT16 AddressSize Offset */ \
+ },
\
+ ARM_GAS32 (UartBase), /*
EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister */ \
+ UartAddrLen, /* UINT32 AddressSize */
\
+ UartNameStr /* UINT8
NameSpaceString[MAX_DBG2_NAME_LEN] */ \
+ }
+
+
+STATIC DBG2_TABLE Dbg2 = {
+ {
+ ACPI_HEADER (
+ EFI_ACPI_5_1_DEBUG_PORT_2_TABLE_SIGNATURE,
+ DBG2_TABLE,
+ EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION
+ ),
+ OFFSET_OF (DBG2_TABLE, Dbg2DeviceInfo),
+ RPI_DBG2_NUM_DEBUG_PORTS /*
UINT32 NumberDbgDeviceInfo */
+ },
+ {
+ /*
+ * Kernel Debug Port
+ */
+ DBG2_DEBUG_PORT_DDI (
+ RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS,
+ EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_BCM2835_UART,
+ RPI_UART_BASE_ADDRESS,
+ RPI_UART_LENGTH,
+ RPI_UART_STR
+ ),
+ }
};