44#define DBG2_NUM_DEBUG_PORTS 1
49#define DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS 1
53#define INDEX_DBG_PORT0 0
57#define NAME_STR_DBG_PORT0 "COM0"
61#define NAMESPACE_STR_DBG_PORT0 "\\_SB_.COM0"
65#define UID_DBG_PORT0 0
69#define DBG2_NAMESPACESTRING_FIELD_SIZE sizeof (NAMESPACE_STR_DBG_PORT0)
73#define PL011_UART_LENGTH 0x1000
111#define DBG2_DEBUG_PORT_DDI( \
119 EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, \
121 sizeof (DBG2_DEBUG_DEVICE_INFORMATION), \
123 DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS, \
125 DBG2_NAMESPACESTRING_FIELD_SIZE, \
127 OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString), \
133 EFI_ACPI_DBG2_PORT_TYPE_SERIAL, \
137 {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}, \
139 OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), \
141 OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize) \
144 ARM_GAS32 (UartBase), \
161 EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION
207 UINT32 ReceiveFifoDepth;
212 ASSERT (SerialPortInfo !=
NULL);
215 DEBUG ((DEBUG_INFO,
"Initializing Serial Debug UART...\n"));
216 ReceiveFifoDepth = 0;
221 BaudRate = SerialPortInfo->BaudRate;
262 ASSERT (This !=
NULL);
263 ASSERT (AcpiTableInfo !=
NULL);
264 ASSERT (CfgMgrProtocol !=
NULL);
265 ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
266 ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
268 if ((Table ==
NULL) ||
272 DEBUG ((DEBUG_ERROR,
"ERROR: DBG2: Invalid Table Pointer\n"));
273 return EFI_INVALID_PARAMETER;
278 if ((TableList[1] ==
NULL) ||
279 (TableList[1]->Signature !=
282 DEBUG ((DEBUG_ERROR,
"ERROR: DBG2: Invalid SSDT table pointer.\n"));
283 return EFI_INVALID_PARAMETER;
334 UINT32 SerialPortCount;
337 ASSERT (This !=
NULL);
338 ASSERT (AcpiTableInfo !=
NULL);
339 ASSERT (CfgMgrProtocol !=
NULL);
340 ASSERT (Table !=
NULL);
341 ASSERT (TableCount !=
NULL);
342 ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
343 ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
345 if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) ||
346 (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision))
350 "ERROR: DBG2: Requested table revision = %d, is not supported."
351 "Supported table revision: Minimum = %d, Maximum = %d\n",
352 AcpiTableInfo->AcpiTableRevision,
353 This->MinAcpiTableRevision,
354 This->AcpiTableRevision
356 return EFI_INVALID_PARAMETER;
361 Status = GetEArchCommonObjSerialDebugPortInfo (
367 if (EFI_ERROR (Status)) {
370 "ERROR: DBG2: Failed to get serial port information. Status = %r\n",
376 if (SerialPortCount == 0) {
379 "ERROR: DBG2: Serial port information not found. Status = %r\n",
382 return EFI_NOT_FOUND;
387 if (EFI_ERROR (Status)) {
390 "ERROR: DBG2: Invalid serial port information. Status = %r\n",
399 if (TableList ==
NULL) {
400 Status = EFI_OUT_OF_RESOURCES;
403 "ERROR: DBG2: Failed to allocate memory for Table List," \
417 if (EFI_ERROR (Status)) {
420 "ERROR: DBG2: Failed to add ACPI header. Status = %r\n",
431 if (SerialPortInfo->
AccessSize >= EFI_ACPI_6_3_QWORD) {
432 Status = EFI_INVALID_PARAMETER;
435 "ERROR: DBG2: Access size must be <= 3 (DWORD). Status = %r\n",
439 }
else if (SerialPortInfo->
AccessSize == EFI_ACPI_6_3_UNDEFINED) {
457 EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART) ||
459 EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART_2X) ||
461 EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART))
468 if (EFI_ERROR (Status)) {
471 "ERROR: DBG2: Failed to configure debug serial port. Status = %r\n",
477 EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_16550_WITH_GAS))
495 if (EFI_ERROR (Status)) {
498 "ERROR: DBG2: Failed to build associated SSDT table. Status = %r\n",
510 if (TableList !=
NULL) {
519#define DBG2_GENERATOR_REVISION CREATE_REVISION (1, 0)
529 L
"ACPI.STD.DBG2.GENERATOR",
533 EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION,
535 EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION,
570 DEBUG ((DEBUG_INFO,
"DBG2: Register Generator. Status = %r\n", Status));
594 DEBUG ((DEBUG_INFO,
"DBG2: Deregister Generator. Status = %r\n", Status));
#define EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE
#define EFI_ACPI_6_3_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
#define EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE
EFI_STATUS EFIAPI RegisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
EFI_STATUS EFIAPI DeregisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
#define CREATE_STD_ACPI_TABLE_GEN_ID(TableId)
#define TABLE_GENERATOR_CREATOR_ID
@ EStdAcpiTableIdDbg2
DBG2 Generator.
#define ACPI_HEADER(Signature, Type, Revision)
@ EArchCommonObjSerialDebugPortInfo
4 - Serial Debug Port Info
RETURN_STATUS EFIAPI Dbg2InitializePort(IN CONST CM_ARCH_COMMON_SERIAL_PORT_INFO *SerialPortInfo, IN OUT UINT64 *BaudRate, IN OUT UINT32 *ReceiveFifoDepth, IN OUT EFI_PARITY_TYPE *Parity, IN OUT UINT8 *DataBits, IN OUT EFI_STOP_BITS_TYPE *StopBits)
#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)
@ EObjNameSpaceArchCommon
Arch Common Objects Namespace.
EFI_STATUS EFIAPI AcpiDbg2LibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define NAME_STR_DBG_PORT0
STATIC EFI_STATUS EFIAPI BuildDbg2TableEx(IN CONST ACPI_TABLE_GENERATOR *This, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, OUT EFI_ACPI_DESCRIPTION_HEADER ***Table, OUT UINTN *CONST TableCount)
EFI_STATUS EFIAPI AcpiDbg2LibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define NAMESPACE_STR_DBG_PORT0
STATIC EFI_STATUS SetupDebugUart(IN CONST CM_ARCH_COMMON_SERIAL_PORT_INFO *CONST SerialPortInfo)
#define DBG2_DEBUG_PORT_DDI( SubType, UartBase, UartAddrLen, UartNameStr)
STATIC CONST ACPI_TABLE_GENERATOR Dbg2Generator
#define DBG2_GENERATOR_REVISION
#define DBG2_NUM_DEBUG_PORTS
STATIC EFI_STATUS EFIAPI FreeDbg2TableEx(IN CONST ACPI_TABLE_GENERATOR *CONST This, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN OUT EFI_ACPI_DESCRIPTION_HEADER ***CONST Table, IN CONST UINTN TableCount)
#define DBG2_NAMESPACESTRING_FIELD_SIZE
STATIC DBG2_TABLE AcpiDbg2
#define PL011_UART_LENGTH
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define OFFSET_OF(TYPE, Field)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define FixedPcdGet8(TokenName)
EFI_STATUS EFIAPI ValidateSerialPortInfo(IN CONST CM_ARCH_COMMON_SERIAL_PORT_INFO *SerialPortInfoTable, IN UINT32 SerialPortCount)
EFI_STATUS EFIAPI FreeSsdtSerialPortTable(IN EFI_ACPI_DESCRIPTION_HEADER *Table)
EFI_STATUS EFIAPI BuildSsdtSerialPortTable(IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *AcpiTableInfo, IN CONST CM_ARCH_COMMON_SERIAL_PORT_INFO *SerialPortInfo, IN CONST CHAR8 *Name, IN CONST UINT64 Uid, OUT EFI_ACPI_DESCRIPTION_HEADER **Table)
EFI_STATUS EFIAPI AddAcpiHeader(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST ACPI_TABLE_GENERATOR *CONST Generator, IN OUT EFI_ACPI_DESCRIPTION_HEADER *CONST AcpiHeader, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST UINT32 Length)
EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister
The base address register for the serial port.
EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT Dbg2Device
The debug device information for the platform.
UINT32 AddressSize
The address size.
EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE Description
The DBG2 table header.
DBG2_DEBUG_DEVICE_INFORMATION Dbg2DeviceInfo[DBG2_NUM_DEBUG_PORTS]
Debug port information list.
UINT16 PortSubtype
Serial Port subtype.
UINT8 AccessSize
The access size.
UINT64 BaseAddress
The physical base address for the serial port.