hc
2024-03-26 e0728245c89800c2038c23308f2d88969d5b41c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Copyright (c) 2018 Linaro Limited
 * Copyright (c) 2018 Hisilicon Limited
 *. All rights reserved.
 * SPDX-License-Identifier: BSD-2-Clause-Patent
 *
*/
 
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/DebugPort2Table.h>
#include <Library/AcpiLib.h>
#include <Library/PcdLib.h>
#include "Hi1620Platform.h"
 
#define NUMBER_DEBUG_DEVICE_INFO    1
#define NUMBER_OF_GENERIC_ADDRESS   1
#define NAMESPACE_STRING_SIZE       12
#define UART_LENGTH                 0x1000
 
#pragma pack(1)
 
typedef struct {
  EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT DdiHeader;
  EFI_ACPI_6_1_GENERIC_ADDRESS_STRUCTURE Address[NUMBER_OF_GENERIC_ADDRESS];
  UINT32 AddressSize[NUMBER_OF_GENERIC_ADDRESS];
  CHAR8  NamespaceString[NAMESPACE_STRING_SIZE];
} EFI_ACPI_DBG2_DDI_STRUCT;
 
typedef struct {
  EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE Desc;
  EFI_ACPI_DBG2_DDI_STRUCT Ddi[NUMBER_DEBUG_DEVICE_INFO];
} EFI_ACPI_DEBUG_PORT_2_TABLE;
 
#pragma pack()
 
EFI_ACPI_DEBUG_PORT_2_TABLE Dbg2 = {
  {
    ARM_ACPI_HEADER(
      EFI_ACPI_6_1_DEBUG_PORT_2_TABLE_SIGNATURE,
      EFI_ACPI_DEBUG_PORT_2_TABLE,
      EFI_ACPI_DEBUG_PORT_2_TABLE_REVISION
      ),
    OFFSET_OF(EFI_ACPI_DEBUG_PORT_2_TABLE, Ddi),
    NUMBER_DEBUG_DEVICE_INFO
  },
  {
    {
      {
        EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION,
        sizeof(EFI_ACPI_DBG2_DDI_STRUCT),
        NUMBER_OF_GENERIC_ADDRESS,
        NAMESPACE_STRING_SIZE,
        OFFSET_OF(EFI_ACPI_DBG2_DDI_STRUCT, NamespaceString),
        0,  //OemDataLength
        0,  //OemDataOffset
        EFI_ACPI_DBG2_PORT_TYPE_SERIAL,
         EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART,
        {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE},
        OFFSET_OF(EFI_ACPI_DBG2_DDI_STRUCT, Address),
        OFFSET_OF(EFI_ACPI_DBG2_DDI_STRUCT, AddressSize),
      },
      {
        {
          EFI_ACPI_6_1_SYSTEM_MEMORY,
          32,
          0,
          EFI_ACPI_6_1_BYTE,
          FixedPcdGet64 (PcdSerialDbgRegisterBase)
        }
      },
      {
        UART_LENGTH
      },
      "\\_SB.COM0"
    }
  }
};
 
//
// Reference the table being generated to prevent the optimizer from removing the
// data structure from the executable
//
VOID* CONST ReferenceAcpiTable = &Dbg2;