Dbg2.aslc 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /** @file
  2. Debug Port Table 2 (DBPG2)
  3. Debug Port Table 2 is used in platform firmware to describe the debug
  4. ports available on the system to the OS. The reference design platforms use
  5. the non-secure UART port in the compute subsystem as the debug port.
  6. Copyright (c) 2018 - 2022, Arm Limited. All rights reserved.
  7. SPDX-License-Identifier: BSD-2-Clause-Patent
  8. @par Specification Reference:
  9. - https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup
  10. /acpi-debug-port-table
  11. **/
  12. #include <IndustryStandard/DebugPort2Table.h>
  13. #include <Library/AcpiLib.h>
  14. #include "SgiAcpiHeader.h"
  15. #define SGI_DBG2_NUM_DEBUG_PORTS 1
  16. #define SGI_DBG2_NUM_GAS 1
  17. #define SGI_DBG2_NS_STR_LENGTH 12
  18. #define SGI_PL011_REGISTER_SPACE 0x1000
  19. #pragma pack(1)
  20. typedef struct {
  21. EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT Dbg2Device;
  22. EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister;
  23. UINT32 AddressSize;
  24. UINT8 NameSpaceString[SGI_DBG2_NS_STR_LENGTH];
  25. } DBG2_DEBUG_DEVICE_INFORMATION;
  26. typedef struct {
  27. EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE Description;
  28. DBG2_DEBUG_DEVICE_INFORMATION Dbg2DeviceInfo[SGI_DBG2_NUM_DEBUG_PORTS];
  29. } DBG2_TABLE;
  30. #pragma pack()
  31. #define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen, UartNameStr) { \
  32. { \
  33. EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, /* UINT8 Revision */ \
  34. sizeof (DBG2_DEBUG_DEVICE_INFORMATION), /* UINT16 Length */ \
  35. NumReg, /* UINT8 NumberofGenericAddressRegisters */ \
  36. SGI_DBG2_NS_STR_LENGTH, /* UINT16 NameSpaceStringLength */ \
  37. OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString), /* UINT16 NameSpaceStringOffset */ \
  38. 0, /* UINT16 OemDataLength */ \
  39. 0, /* UINT16 OemDataOffset */ \
  40. EFI_ACPI_DBG2_PORT_TYPE_SERIAL, /* UINT16 Port Type */ \
  41. SubType, /* UINT16 Port Subtype */ \
  42. { EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE }, /* UINT8 Reserved[2] */ \
  43. OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), /* UINT16 BaseAddressRegister Offset */ \
  44. OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize) /* UINT16 AddressSize Offset */ \
  45. }, \
  46. ARM_GAS32 (UartBase), /* EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister */ \
  47. UartAddrLen, /* UINT32 AddressSize */ \
  48. UartNameStr /* UINT8 NameSpaceString[MAX_DBG2_NAME_LEN] */ \
  49. }
  50. STATIC DBG2_TABLE Dbg2 = {
  51. {
  52. ARM_ACPI_HEADER (
  53. EFI_ACPI_6_4_DEBUG_PORT_2_TABLE_SIGNATURE,
  54. DBG2_TABLE,
  55. EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION
  56. ),
  57. OFFSET_OF (DBG2_TABLE, Dbg2DeviceInfo),
  58. SGI_DBG2_NUM_DEBUG_PORTS
  59. },
  60. {
  61. // Kernel Debug Port
  62. DBG2_DEBUG_PORT_DDI (
  63. SGI_DBG2_NUM_GAS,
  64. EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART,
  65. FixedPcdGet64 (PcdSerialDbgRegisterBase),
  66. SGI_PL011_REGISTER_SPACE,
  67. "\\_SB.COM0"
  68. )
  69. }
  70. };
  71. //
  72. // Reference the table being generated to prevent the optimizer from removing
  73. // the data structure from the executable
  74. //
  75. VOID* CONST ReferenceAcpiTable = &Dbg2;