• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/** @file
2*  DBG2 Table
3*
4*  Copyright (c) 2012-2016, ARM Limited. All rights reserved.
5*
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*
11*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13*
14**/
15
16#include "ArmPlatform.h"
17#include <Library/AcpiLib.h>
18#include <Library/ArmLib.h>
19#include <Library/PcdLib.h>
20#include <IndustryStandard/Acpi.h>
21#include <IndustryStandard/DebugPort2Table.h>
22
23#pragma pack(1)
24
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 PL011_UART_LENGTH                          0x1000
29
30#define NAME_STR_UART1     {'C', 'O', 'M', '1', '\0', '\0', '\0', '\0'}
31
32typedef struct {
33  EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT Dbg2Device;
34  EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE        BaseAddressRegister;
35  UINT32                                        AddressSize;
36  UINT8                                         NameSpaceString[DBG2_NAMESPACESTRING_FIELD_SIZE];
37} DBG2_DEBUG_DEVICE_INFORMATION;
38
39typedef struct {
40  EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE       Description;
41  DBG2_DEBUG_DEVICE_INFORMATION                 Dbg2DeviceInfo[DBG2_NUM_DEBUG_PORTS];
42} DBG2_TABLE;
43
44
45#define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen, UartNameStr) {                                    \
46    {                                                                                                                 \
47      EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION,         /* UINT8     Revision */                        \
48      sizeof (DBG2_DEBUG_DEVICE_INFORMATION),                         /* UINT16    Length */                          \
49      NumReg,                                                         /* UINT8     NumberofGenericAddressRegisters */ \
50      DBG2_NAMESPACESTRING_FIELD_SIZE,                                /* UINT16    NameSpaceStringLength */           \
51      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString),     /* UINT16    NameSpaceStringOffset */           \
52      0,                                                              /* UINT16    OemDataLength */                   \
53      0,                                                              /* UINT16    OemDataOffset */                   \
54      EFI_ACPI_DBG2_PORT_TYPE_SERIAL,                                 /* UINT16    Port Type */                       \
55      SubType,                                                        /* UINT16    Port Subtype */                    \
56      {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE},               /* UINT8     Reserved[2] */                     \
57      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), /* UINT16    BaseAddressRegister Offset */      \
58      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize)          /* UINT16    AddressSize Offset */              \
59    },                                                                                                                \
60    ARM_GAS32 (UartBase),                            /* EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister */ \
61    UartAddrLen,                                     /* UINT32  AddressSize */                                        \
62    UartNameStr                                      /* UINT8   NameSpaceString[MAX_DBG2_NAME_LEN] */                 \
63  }
64
65
66STATIC DBG2_TABLE Dbg2 = {
67  {
68    ARM_ACPI_HEADER (EFI_ACPI_5_1_DEBUG_PORT_2_TABLE_SIGNATURE,
69                       DBG2_TABLE,
70                       EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION),
71    OFFSET_OF (DBG2_TABLE, Dbg2DeviceInfo),
72    DBG2_NUM_DEBUG_PORTS                                              /* UINT32  NumberDbgDeviceInfo */
73  },
74  {
75    /*
76     * Kernel Debug Port
77     */
78    DBG2_DEBUG_PORT_DDI (DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS,
79                          EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART,
80                          FixedPcdGet64 (PcdSerialDbgRegisterBase),
81                          PL011_UART_LENGTH,
82                          NAME_STR_UART1),
83  }
84};
85
86#pragma pack()
87
88//
89// Reference the table being generated to prevent the optimizer from removing
90// the data structure from the executable
91//
92VOID* CONST ReferenceAcpiTable = &Dbg2;
93