summaryrefslogtreecommitdiff
path: root/Platform/ARM/SgiPkg/AcpiTables/RdDanielCfgXlr/Madt.aslc
blob: 0da56ed2a39b0781b9bb481b1b0d52c3460fe387 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/** @file
*  Multiple APIC Description Table (MADT)
*
*  Copyright (c) 2020, Arm Limited. All rights reserved.
*
*  SPDX-License-Identifier: BSD-2-Clause-Patent
*
**/

#include "SgiPlatform.h"
#include "SgiAcpiHeader.h"
#include <Library/AcpiLib.h>
#include <Library/ArmLib.h>
#include <Library/PcdLib.h>
#include <IndustryStandard/Acpi.h>

#define CORE_CNT   (FixedPcdGet32 (PcdClusterCount) * \
                      FixedPcdGet32 (PcdCoreCount))
#define CHIP_CNT   FixedPcdGet32 (PcdChipCount)

// Multiple APIC Description Table
#pragma pack (1)

typedef struct {
  EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER  Header;
  EFI_ACPI_6_2_GIC_STRUCTURE                           GicInterfaces[CORE_CNT * CHIP_CNT];
  EFI_ACPI_6_2_GIC_DISTRIBUTOR_STRUCTURE               GicDistributor;
  EFI_ACPI_6_2_GICR_STRUCTURE                          GicRedistributor[CHIP_CNT];
  EFI_ACPI_6_2_GIC_ITS_STRUCTURE                       GicIts[4];
} EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE;

#pragma pack ()

STATIC EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
  {
    ARM_ACPI_HEADER (
      EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
      EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE,
      EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION
    ),
    // MADT specific fields
    0, // LocalApicAddress
    0  // Flags
  },
  {
    // Format: EFI_ACPI_6_2_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags,
    //                                          PmuIrq, GicBase, GicVBase,
    //                                          GicHBase, GsivId, GicRBase,
    //                                          Efficiency)
    // Note: The GIC Structure of the primary CPU must be the first entry
    // (see note in 5.2.12.14 GICC Structure of ACPI v6.2).
    //Chip 0
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core0
      0, 0, GET_MPID(0x0, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core1
      0, 1, GET_MPID(0x100, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core2
      0, 2, GET_MPID(0x200, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core3
      0, 3, GET_MPID(0x300, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),

    // Chip 1
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core0
      0, 0, GET_MPID(0x01000000ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core1
      0, 1, GET_MPID(0x01000100ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core2
      0, 2, GET_MPID(0x01000200ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core3
      0, 3, GET_MPID(0x01000300ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),

    // Chip 2
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core0
      0, 0, GET_MPID(0x02000000ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core1
      0, 1, GET_MPID(0x02000100ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core2
      0, 2, GET_MPID(0x02000200ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core3
      0, 3, GET_MPID(0x02000300ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),

    // Chip 3
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core0
      0, 0, GET_MPID(0x03000000ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core1
      0, 1, GET_MPID(0x03000100ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core2
      0, 2, GET_MPID(0x03000200ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
    EFI_ACPI_6_2_GICC_STRUCTURE_INIT( // Zeus core3
      0, 3, GET_MPID(0x03000300ULL, 0x0), EFI_ACPI_6_2_GIC_ENABLED, 23,
      FixedPcdGet32 (PcdGicDistributorBase),
      0x2c020000, 0x2c010000, 25, 0 /* GicRBase */, 0 /* Efficiency */),
  },
  // GIC Distributor Entry
  EFI_ACPI_6_2_GIC_DISTRIBUTOR_INIT(0, FixedPcdGet32 (PcdGicDistributorBase),
                                    0, 3),
  {
    // GIC Redistributor
    EFI_ACPI_6_2_GIC_REDISTRIBUTOR_INIT(FixedPcdGet32 (PcdGicRedistributorsBase) +
      SGI_REMOTE_CHIP_MEM_OFFSET(0), SIZE_16MB),
    EFI_ACPI_6_2_GIC_REDISTRIBUTOR_INIT(FixedPcdGet32 (PcdGicRedistributorsBase) +
      SGI_REMOTE_CHIP_MEM_OFFSET(1), SIZE_16MB),
    EFI_ACPI_6_2_GIC_REDISTRIBUTOR_INIT(FixedPcdGet32 (PcdGicRedistributorsBase) +
      SGI_REMOTE_CHIP_MEM_OFFSET(2), SIZE_16MB),
    EFI_ACPI_6_2_GIC_REDISTRIBUTOR_INIT(FixedPcdGet32 (PcdGicRedistributorsBase) +
      SGI_REMOTE_CHIP_MEM_OFFSET(3), SIZE_16MB)
  },
  // GIC ITS
  {
    EFI_ACPI_6_2_GIC_ITS_INIT(0, 0x30040000),
    EFI_ACPI_6_2_GIC_ITS_INIT(1, 0x30080000),
    EFI_ACPI_6_2_GIC_ITS_INIT(2, 0x300C0000),
    EFI_ACPI_6_2_GIC_ITS_INIT(3, 0x30100000),
  },
};

//
// Reference the table being generated to prevent the optimizer from removing
// the data structure from the executable
//
VOID* CONST ReferenceAcpiTable = &Madt;