Dbg2.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /** @file
  2. Microsoft Debug Port Table 2 (DBG2)
  3. © 2012 Microsoft. All rights reserved.<BR>
  4. http://go.microsoft.com/fwlink/p/?linkid=403551
  5. Copyright (c) 2014 - 2016, AMD Inc. All rights reserved.<BR>
  6. This program and the accompanying materials
  7. are licensed and made available under the terms and conditions of the BSD License
  8. which accompanies this distribution. The full text of the license may be found at
  9. http://opensource.org/licenses/bsd-license.php
  10. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  12. **/
  13. #include <AmdStyxAcpiLib.h>
  14. #include <IndustryStandard/DebugPort2Table.h>
  15. #pragma pack(push, 1)
  16. #define EFI_ACPI_DBG2_REVISION 0
  17. #define DBG2_NUM_DEBUG_PORTS 1
  18. #define DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS 1
  19. #define DBG2_NAMESPACESTRING_FIELD_SIZE 8
  20. #define DBG2_OEM_DATA_FIELD_SIZE 0
  21. #define DBG2_OEM_DATA_FIELD_OFFSET 0
  22. #define DBG2_DEBUG_PORT_SUBTYPE_PL011 0x0003 // Sub type for Pl011
  23. #define DBG2_DEBUG_PORT_SUBTYPE_UEFI 0x0007 // Sub type for UEFI Debug Port
  24. #define PL011_UART_LENGTH 0x1000
  25. #define NAME_STR_UART1 {'C', 'O', 'M', '1', '\0', '\0', '\0', '\0'}
  26. #define NAME_STR_UEFI {'U', 'E', 'F', 'I', '\0', '\0', '\0', '\0'}
  27. typedef struct {
  28. EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT Dbg2Device;
  29. EFI_ACPI_5_0_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister;
  30. UINT32 AddressSize;
  31. UINT8 NameSpaceString[DBG2_NAMESPACESTRING_FIELD_SIZE];
  32. } DBG2_DEBUG_DEVICE_INFORMATION;
  33. typedef struct {
  34. EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE Description;
  35. DBG2_DEBUG_DEVICE_INFORMATION Dbg2DeviceInfo[DBG2_NUM_DEBUG_PORTS];
  36. } DBG2_TABLE;
  37. #define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen, UartNameStr) { \
  38. { \
  39. EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, /* UINT8 Revision; */ \
  40. sizeof (DBG2_DEBUG_DEVICE_INFORMATION), /* UINT16 Length; */ \
  41. NumReg, /* UINT8 NumberofGenericAddressRegisters; */ \
  42. DBG2_NAMESPACESTRING_FIELD_SIZE, /* UINT16 NameSpaceStringLength; */ \
  43. OFFSET_OF(DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString), /* UINT16 NameSpaceStringOffset; */ \
  44. DBG2_OEM_DATA_FIELD_SIZE, /* UINT16 OemDataLength; */ \
  45. DBG2_OEM_DATA_FIELD_OFFSET, /* UINT16 OemDataOffset; */ \
  46. EFI_ACPI_DBG2_PORT_TYPE_SERIAL, /* UINT16 Port Type; */ \
  47. SubType, /* UINT16 Port Subtype; */ \
  48. {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}, /* UINT8 Reserved[2]; */ \
  49. OFFSET_OF(DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), /* UINT16 BaseAddressRegister Offset; */ \
  50. OFFSET_OF(DBG2_DEBUG_DEVICE_INFORMATION, AddressSize) /* UINT16 AddressSize Offset; */ \
  51. }, \
  52. AMD_GASN (UartBase), /* EFI_ACPI_5_0_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister */ \
  53. UartAddrLen, /* UINT32 AddressSize */ \
  54. UartNameStr /* UINT8 NameSpaceString[MAX_DBG2_NAME_LEN] */ \
  55. }
  56. STATIC DBG2_TABLE AcpiDbg2 = {
  57. {
  58. AMD_ACPI_HEADER (EFI_ACPI_5_0_DEBUG_PORT_2_TABLE_SIGNATURE,
  59. DBG2_TABLE,
  60. EFI_ACPI_DBG2_REVISION),
  61. OFFSET_OF(DBG2_TABLE, Dbg2DeviceInfo),
  62. DBG2_NUM_DEBUG_PORTS // UINT32 NumberDbgDeviceInfo
  63. },
  64. {
  65. /*
  66. * Kernel Debug Port
  67. */
  68. #if (DBG2_NUM_DEBUG_PORTS > 0)
  69. DBG2_DEBUG_PORT_DDI(DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS,
  70. DBG2_DEBUG_PORT_SUBTYPE_PL011,
  71. FixedPcdGet64(PcdSerialDbgRegisterBase),
  72. PL011_UART_LENGTH,
  73. NAME_STR_UART1),
  74. #endif
  75. /*
  76. * UEFI Debug Port
  77. */
  78. #if (DBG2_NUM_DEBUG_PORTS > 1)
  79. DBG2_DEBUG_PORT_DDI(0,
  80. DBG2_DEBUG_PORT_SUBTYPE_UEFI,
  81. 0,
  82. 0,
  83. NAME_STR_UEFI),
  84. #endif
  85. }
  86. };
  87. #pragma pack(pop)
  88. EFI_ACPI_DESCRIPTION_HEADER *
  89. Dbg2Header (
  90. VOID
  91. )
  92. {
  93. return &AcpiDbg2.Description.Header;
  94. }