Hi Philippe, On 2019.12.18 15:57, Philippe Mathieu-Daudé wrote:
On 12/18/19 12:41 PM, Pete Batard wrote: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.infindex 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.PcdInterruptBaseAddressdiff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslcindex 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 addressActually this is the other way around, the 8250 is at AUX + 0x40. Can we clean that up or is it too late?
Yeah, re-reading this I admit the comment is not too clear. Let me try to rephrase this better in v2. Regards, /Pete
+//+#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 + ), + } };[...]
-=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52365): https://edk2.groups.io/g/devel/message/52365 Mute This Topic: https://groups.io/mt/68791813/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-