Dbg2MiniUart.aslc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /** @file
  2. *
  3. * Debug Port Table (DBG2)
  4. *
  5. * Copyright (c) 2019, Pete Batard <pete@akeo.ie>
  6. * Copyright (c) 2012-2021, ARM Limited. All rights reserved.
  7. *
  8. * SPDX-License-Identifier: BSD-2-Clause-Patent
  9. *
  10. **/
  11. #include <IndustryStandard/Acpi.h>
  12. #include <IndustryStandard/Bcm2836.h>
  13. #include <IndustryStandard/RpiDebugPort2Table.h>
  14. #include <Library/AcpiLib.h>
  15. #include <Library/PcdLib.h>
  16. #include "AcpiTables.h"
  17. #pragma pack(1)
  18. #define RPI_UART_INTERFACE_TYPE EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_BCM2835_UART
  19. #define RPI_UART_BASE_ADDRESS BCM2836_MINI_UART_BASE_ADDRESS
  20. #define RPI_UART_LENGTH BCM2836_MINI_UART_LENGTH
  21. //
  22. // RPI_UART_STR should match the value used Uart.asl
  23. //
  24. #define RPI_UART_STR { '\\', '_', 'S', 'B', '.', 'G', 'D', 'V', '0', '.', 'U', 'R', 'T', 'M', 0x00 }
  25. #define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen, UartNameStr) { \
  26. { \
  27. EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, /* UINT8 Revision */ \
  28. sizeof (DBG2_DEBUG_DEVICE_INFORMATION), /* UINT16 Length */ \
  29. NumReg, /* UINT8 NumberofGenericAddressRegisters */ \
  30. RPI_DBG2_NAMESPACESTRING_FIELD_SIZE, /* UINT16 NameSpaceStringLength */ \
  31. OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString), /* UINT16 NameSpaceStringOffset */ \
  32. 0, /* UINT16 OemDataLength */ \
  33. 0, /* UINT16 OemDataOffset */ \
  34. EFI_ACPI_DBG2_PORT_TYPE_SERIAL, /* UINT16 Port Type */ \
  35. SubType, /* UINT16 Port Subtype */ \
  36. {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}, /* UINT8 Reserved[2] */ \
  37. OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), /* UINT16 BaseAddressRegister Offset */ \
  38. OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize) /* UINT16 AddressSize Offset */ \
  39. }, \
  40. ARM_GAS32 (UartBase), /* EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister */ \
  41. UartAddrLen, /* UINT32 AddressSize */ \
  42. UartNameStr /* UINT8 NameSpaceString[MAX_DBG2_NAME_LEN] */ \
  43. }
  44. STATIC DBG2_TABLE Dbg2 = {
  45. {
  46. ACPI_HEADER (
  47. EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE,
  48. DBG2_TABLE,
  49. EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION
  50. ),
  51. OFFSET_OF (DBG2_TABLE, Dbg2DeviceInfo),
  52. RPI_DBG2_NUM_DEBUG_PORTS /* UINT32 NumberDbgDeviceInfo */
  53. },
  54. {
  55. /*
  56. * Kernel Debug Port
  57. */
  58. DBG2_DEBUG_PORT_DDI (
  59. RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS,
  60. RPI_UART_INTERFACE_TYPE,
  61. RPI_UART_BASE_ADDRESS,
  62. RPI_UART_LENGTH,
  63. RPI_UART_STR
  64. ),
  65. }
  66. };
  67. #pragma pack()
  68. //
  69. // Reference the table being generated to prevent the optimizer from removing
  70. // the data structure from the executable
  71. //
  72. VOID* CONST ReferenceAcpiTable = &Dbg2;