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