Skip to content

Commit 4f37401

Browse files
committed
add iort nodes structure.
1 parent 17c7974 commit 4f37401

File tree

3 files changed

+273
-1
lines changed

3 files changed

+273
-1
lines changed

include/common/dbg2.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ typedef struct {
2020
} __attribute__((packed)) ACPI_GAS;
2121
_Static_assert(sizeof(ACPI_GAS) == 12, "ACPI_GAS size incorrect");
2222

23-
/* Body Structures */
23+
/* Header Extra Data */
2424
typedef struct {
2525
UINT32 OffsetDbgDeviceInfo;
2626
UINT32 NumberOfDbgDevices;
@@ -29,6 +29,7 @@ typedef struct {
2929
_Static_assert(sizeof(DBG2_HEADER_EXTRA_DATA) == 8,
3030
"DBG2_HEADER_EXTRA_DATA size incorrect");
3131

32+
/* Body Structures */
3233
enum DBG2_DEBUG_PORT_TYPE {
3334
DBG2_DEBUG_PORT_TYPE_RESERVED = 0,
3435
/* 0-0x7FFF are reserved */

include/common/iort.h

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
#pragma once
2+
#include <acpi.h>
3+
#include <common.h>
4+
5+
/** IO Remapping Table (IORT)
6+
Reference:
7+
https://developer.arm.com/documentation/den0049/latest
8+
*/
9+
10+
/* Table signature */
11+
#define ACPI_IORT_SIGNATURE 'I', 'O', 'R', 'T'
12+
#define ACPI_IORT_REVISION 7
13+
14+
#define ACPI_IORT_TABLE_STRUCTURE_NAME IO_REMAPPING_TABLE
15+
16+
/* Header Extra Data */
17+
typedef struct {
18+
UINT32 NumOfNodes;
19+
UINT32 OffsetToNodeArray;
20+
UINT32 Reserved;
21+
/* Optional padding */
22+
/* Arrary of iort nodes */
23+
} __attribute__((packed)) IORT_HEADER_EXTRA_DATA;
24+
_Static_assert(sizeof(IORT_HEADER_EXTRA_DATA) == 12,
25+
"IORT_HEADER_EXTRA_DATA size incorrect");
26+
27+
/* Body Structures */
28+
typedef struct {
29+
UINT8 Type; // Check iort node type
30+
UINT16 Length;
31+
UINT8 Revision;
32+
UINT32 Identifier;
33+
UINT32 NumOfIDMappings;
34+
UINT32 ReferenceToIdArray;
35+
// Data Specific to Node
36+
// Array of ID mappings
37+
} __attribute__((packed)) IORT_NODE_FORMAT;
38+
_Static_assert(sizeof(IORT_NODE_FORMAT) == 16,
39+
"IORT_NODE_FORMAT size incorrect");
40+
41+
typedef struct {
42+
UINT32 InputBase;
43+
UINT32 NumOfIds;
44+
UINT32 OutputBase;
45+
UINT32 OutputReference;
46+
UINT32 Flags;
47+
} __attribute__((packed)) IORT_ID_MAPPING_FORMAT;
48+
_Static_assert(sizeof(IORT_ID_MAPPING_FORMAT) == 20,
49+
"IORT_ID_MAPPING_FORMAT size incorrect");
50+
51+
// ID Mapping Flags
52+
#define IORT_ID_MAPPING_FLAG_SINGLE_MAPPING BIT(0)
53+
#define IORT_ID_MAPPING_FLAG_RESERVED GEN_MSK(31, 1)
54+
55+
enum IORT_NODE_TYPE {
56+
IORT_NODE_TYPE_ITS_GROUP = 0,
57+
IORT_NODE_TYPE_NAMED_COMPONENT = 1,
58+
IORT_NODE_TYPE_ROOT_COMPLEX = 2,
59+
IORT_NODE_TYPE_SMMU_V1_V2 = 3,
60+
IORT_NODE_TYPE_SMMU_V3 = 4,
61+
IORT_NODE_TYPE_PMCG = 5,
62+
IORT_NODE_TYPE_MEMORY_RANGE = 6,
63+
IORT_NODE_TYPE_IWB = 7,
64+
IORT_NODE_TYPE_RESERVED = 0xFF
65+
};
66+
67+
typedef struct {
68+
UINT32 CCA; // Cache Coherency Attribute
69+
UINT8 AH; // Allocation Hint
70+
UINT16 Reserved;
71+
UINT8 MAF; // Memory Access Flags
72+
} __attribute__((packed)) IORT_MEMORY_ACCESS_PROPERTIES;
73+
_Static_assert(sizeof(IORT_MEMORY_ACCESS_PROPERTIES) == 8,
74+
"IORT_MEMORY_ACCESS_PROPERTIES size incorrect");
75+
76+
// Coherent Path to Memory
77+
#define IORT_MEMORY_ACCESS_FLAG_CPM BIT(0)
78+
// Device attribute are cacheable and inner sharable
79+
#define IORT_MEMORY_ACCESS_FLAG_DCAS BIT(1)
80+
// Coherency of Accesses not marked inner/outer WB cacheable shareable
81+
#define IORT_MEMORY_ACCESS_FLAG_CANWBS BIT(2)
82+
#define IORT_MEMORY_ACCESS_FLAG_RESERVED GEN_MSK(31, 3)
83+
84+
// IORT node types (chapter 2.1)
85+
// Revision should be 3
86+
typedef struct {
87+
IORT_NODE_FORMAT NodeHeader;
88+
// smmu v1/v2 specific data
89+
UINT64 BaseAddress;
90+
UINT64 Span;
91+
UINT32 Model; // Check IORT_SMMU_V1_V2_MODEL
92+
UINT32 Flags;
93+
UINT32 ReferenceToGlobalInterruptArray;
94+
UINT32 NumOfContextInterrupts;
95+
UINT32 ReferenceToContextInterruptArray;
96+
UINT32 NumOfPMUInterrupts;
97+
UINT32 ReferenceToPMUInterruptArray;
98+
// Global interrupt array section
99+
UINT32 SMMUNSgIrpt;
100+
UINT32 SMMUNSgIrptInterruptFlags;
101+
UINT32 SMMUNSgCfgIrpt;
102+
UINT32 SMMUNSgCfgIrptInterruptFlags;
103+
// Context interrupt array section
104+
// PMU interrupt array section
105+
// IDs for SMMUv1/v2 section
106+
} __attribute__((packed)) IORT_SMMU_V1_V2_NODE;
107+
_Static_assert(sizeof(IORT_SMMU_V1_V2_NODE) == 76,
108+
"IORT_SMMU_V1_V2_NODE size incorrect");
109+
110+
enum IORT_SMMU_V1_V2_MODEL {
111+
IORT_SMMU_V1_V2_MODEL_GENERIC_SMMU_V1 = 0,
112+
IORT_SMMU_V1_V2_MODEL_GENERIC_SMMU_V2 = 1,
113+
IORT_SMMU_V1_V2_MODEL_ARM_MMU400 = 2,
114+
IORT_SMMU_V1_V2_MODEL_ARM_MMU500 = 3,
115+
IORT_SMMU_V1_V2_MODEL_ARM_MMU401 = 4,
116+
IORT_SMMU_V1_V2_MODEL_CAVIUM_THUNDERX_SMMUV2 = 5,
117+
IORT_SMMU_V1_V2_MODEL_RESERVED = 0xFFFFFFFF
118+
};
119+
120+
#define IORT_SMMU_V1_V2_DVM_SUPPORT BIT(0)
121+
#define IORT_SMMU_V1_V2_COHERENT_PAGE_TABLE_WALK BIT(1)
122+
#define IORT_SMMU_V1_V2_RESERVED GEN_MSK(31, 2)
123+
124+
// 0 => level triggered
125+
// 1 => edge triggered
126+
#define IORT_SMMU_V1_V2_INTERRUPT_FLAG BIT(0)
127+
enum IORT_SMMU_V1_V2_INTERRUPT_FLAG_TYPE {
128+
IORT_SMMU_V1_V2_INTERRUPT_FLAG_TYPE_LEVEL = 0,
129+
IORT_SMMU_V1_V2_INTERRUPT_FLAG_TYPE_EDGE = 1,
130+
};
131+
#define IORT_SMMU_V1_V2_INTERRUPT_FLAG_RESERVED GEN_MSK(31, 1)
132+
133+
// SMMUv3 node type
134+
// Revision should be 5
135+
typedef struct {
136+
IORT_NODE_FORMAT NodeHeader;
137+
// Smmu v3 specific data
138+
UINT64 BaseAddress;
139+
UINT32 Flags;
140+
UINT32 Reserved;
141+
UINT64 VATOSAddress;
142+
UINT32 Model; // Check IORT_SMMU_V3_MODEL
143+
UINT32 Event;
144+
UINT32 PRI;
145+
UINT32 GERR;
146+
UINT32 Sync;
147+
UINT32 ProximityDomain;
148+
UINT32 DeviceIDMappingIndex;
149+
// IDs for SMMUv3 section
150+
// Array of ID mappings
151+
} __attribute__((packed)) IORT_SMMU_V3_NODE;
152+
_Static_assert(sizeof(IORT_SMMU_V3_NODE) == 68,
153+
"IORT_SMMU_V3_NODE size incorrect");
154+
155+
enum IORT_SMMU_V3_MODEL {
156+
IORT_SMMU_V3_MODEL_GENERIC_SMMU_V3 = 0,
157+
IORT_SMMU_V3_MODEL_HISI_HI161_SMMU_V3 = 1,
158+
IORT_SMMU_V3_MODEL_CAVIUM_CN99XX_SMMU_V3 = 2,
159+
IORT_SMMU_V3_MODEL_RESERVED = 0xFFFFFFFF
160+
};
161+
162+
#define IORT_SMMU_V3_COHACC_OVERRIDE BIT(0)
163+
#define IORT_SMMU_V3_HTTU_OVERRIDE GEN_MSK(2, 1)
164+
#define IORT_SMMU_V3_PROXIMITY_DOMAIN_VALID BIT(3)
165+
#define IORT_SMMU_V3_DEVICE_ID_MAPPING_INDEX_VALID BIT(4)
166+
#define IORT_SMMU_V3_RESERVED GEN_MSK(31, 5)
167+
168+
// Performance Monitoring counter group
169+
// Revision should be 2
170+
typedef struct {
171+
IORT_NODE_FORMAT NodeHeader;
172+
// pmcg specific data
173+
UINT64 Page0BaseAddress;
174+
UINT32 OverflowInterruptGSIV;
175+
UINT32 NodeReference;
176+
UINT64 Page1BaseAddress;
177+
// IDs for named component
178+
} __attribute__((packed)) IORT_PMCG_NODE;
179+
180+
// ITS Group node format
181+
// Revision should be 1
182+
typedef struct {
183+
IORT_NODE_FORMAT NodeHeader;
184+
// its group specific data
185+
UINT32 NumOfITS;
186+
// UINT32 GicITSIdentifierArrary[];
187+
} __attribute__((packed)) IORT_ITS_GROUP_NODE;
188+
189+
// Named component node format
190+
// Revision should be 4
191+
typedef struct {
192+
IORT_NODE_FORMAT NodeHeader;
193+
// named component specific data
194+
UINT32 Flags;
195+
IORT_MEMORY_ACCESS_PROPERTIES MemAccessProps;
196+
UINT8 DeviceMemoryAddressSizeLimit;
197+
// CHAR8 DeviceObjectName[]; // Null-terminated string
198+
// UINT8 Padding[]; // to 32 bit word align
199+
// Array of IDs mapping
200+
} __attribute__((packed)) IORT_NAMED_COMPONENT_NODE;
201+
_Static_assert(sizeof(IORT_NAMED_COMPONENT_NODE) == 29,
202+
"IORT_NAMED_COMPONENT_NODE size incorrect");
203+
204+
#define IORT_NAMED_COMPONENT_FLAG_STALL_SUPPORTED BIT(0)
205+
// Number of substreams bits supported by this device.
206+
#define IORT_NAMED_COMPONENT_FLAG_SUBSTREAM_WIDTH GEN_MSK(5, 1)
207+
208+
// PCI Root Complex node format
209+
// Revision should be 4
210+
typedef struct {
211+
IORT_NODE_FORMAT NodeHeader;
212+
// pci root complex specific data
213+
IORT_MEMORY_ACCESS_PROPERTIES MemAccessProps;
214+
UINT32 ATSAttribute;
215+
UINT32 PCISegmentNumber;
216+
UINT8 MemoryAddressSizeLimit;
217+
UINT16 PASIDCapabilities;
218+
UINT8 Reserved;
219+
UINT32 Flags;
220+
// IDs for root complex
221+
} __attribute__((packed)) IORT_PCI_ROOT_COMPLEX_NODE;
222+
_Static_assert(sizeof(IORT_PCI_ROOT_COMPLEX_NODE) == 40,
223+
"IORT_PCI_ROOT_COMPLEX_NODE size incorrect");
224+
225+
#define IORT_PCI_ROOT_COMPLEX_FLAG_PASID_SUPPORT BIT(0)
226+
enum IORT_PCI_ROOT_COMPLEX_PASID_CAP {
227+
IORT_PCI_ROOT_COMPLEX_PASID_NOT_SUPPORTED = 0,
228+
IORT_PCI_ROOT_COMPLEX_PASID_SUPPORTED = 1
229+
};
230+
231+
typedef struct {
232+
UINT64 PhysicalRangeOffset;
233+
UINT64 PhysicalRangeLength;
234+
UINT32 Reserved;
235+
} __attribute__((packed)) IORT_MEMORY_RANGE_DESCIPTOR;
236+
_Static_assert(sizeof(IORT_MEMORY_RANGE_DESCIPTOR) == 20,
237+
"IORT_MEMORY_RANGE_DESCIPTOR size incorrect");
238+
239+
// Reserved Memory Range node format
240+
// RMR is used to describe memory ranges that are reserved for use by endpoints.
241+
// Revision should be 3
242+
typedef struct {
243+
IORT_NODE_FORMAT NodeHeader;
244+
// reserved memory range specific data
245+
UINT32 Flags;
246+
UINT32 NumOfMemoryRangeDescriptors;
247+
UINT32 ReferenceToMemoryRangeDescriptor;
248+
} __attribute__((packed)) IORT_RESERVED_MEMORY_RANGE_NODE;
249+
_Static_assert(sizeof(IORT_RESERVED_MEMORY_RANGE_NODE) == 28,
250+
"IORT_RESERVED_MEMORY_RANGE_NODE size incorrect");
251+
252+
// 0x1 => allow, 0x0 => disallow
253+
#define IORT_RMR_FLAG_REMAPPING_PERMITTED BIT(0)
254+
#define IORT_RMR_FLAG_ACCESS_PRIVILEGED BIT(1)
255+
#define IORT_RMR_FLAG_ACCESS_ATTRIBUTES GEN_MSK(9, 2)
256+
#define IORT_RMR_FLAG_RESERVED GEN_MSK(31, 10)
257+
258+
// IWB node format
259+
// Revision should be 1
260+
typedef struct {
261+
IORT_NODE_FORMAT NodeHeader;
262+
// Padding to 0x10 aligned
263+
UINT32 Reserved;
264+
// iwb specific data
265+
UINT64 ConfigFrameBase;
266+
UINT16 IWBIndex;
267+
// CHAR8 DeviceObjectName[]; // Null-terminated string
268+
// UINT8 Padding[]; // to 32 bit word align
269+
// Array of IDs mapping
270+
} __attribute__((packed)) IORT_IWB_NODE;
271+
_Static_assert(sizeof(IORT_IWB_NODE) == 30, "IORT_IWB_NODE size incorrect");

include/vendor/qcom/sm8850/iort.h

Whitespace-only changes.

0 commit comments

Comments
 (0)