TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmGicItsParser.c
Go to the documentation of this file.
1
12#include "CmObjectDescUtility.h"
13#include "FdtHwInfoParser.h"
16
34EFIAPI
36 IN CONST VOID *Fdt,
37 IN INT32 GicIntcNode,
38 IN UINT32 GicItsId,
39 IN CM_ARM_GIC_ITS_INFO *GicItsInfo
40 )
41{
42 EFI_STATUS Status;
43 INT32 AddressCells;
44 CONST UINT8 *Data;
45 INT32 DataSize;
46
47 if ((Fdt == NULL) ||
48 (GicItsInfo == NULL))
49 {
50 ASSERT (0);
51 return EFI_INVALID_PARAMETER;
52 }
53
54 Status = FdtGetParentAddressInfo (Fdt, GicIntcNode, &AddressCells, NULL);
55 if (EFI_ERROR (Status)) {
56 ASSERT (0);
57 return Status;
58 }
59
60 // Don't support more than 64 bits and less than 32 bits addresses.
61 if ((AddressCells < 1) ||
62 (AddressCells > 2))
63 {
64 ASSERT (0);
65 return EFI_ABORTED;
66 }
67
68 Data = fdt_getprop (Fdt, GicIntcNode, "reg", &DataSize);
69 if ((Data == NULL) || (DataSize < (INT32)(AddressCells * sizeof (UINT32)))) {
70 // If error or not enough space.
71 ASSERT (0);
72 return EFI_ABORTED;
73 }
74
75 if (AddressCells == 2) {
76 GicItsInfo->PhysicalBaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
77 } else {
78 GicItsInfo->PhysicalBaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
79 }
80
81 // Gic Its Id
82 GicItsInfo->GicItsId = GicItsId;
83
84 // {default = 0}
85 GicItsInfo->ProximityDomain = 0;
86 return Status;
87}
88
117EFIAPI
119 IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle,
120 IN INT32 FdtBranch
121 )
122{
123 EFI_STATUS Status;
124 UINT32 GicVersion;
125 CM_ARM_GIC_ITS_INFO GicItsInfo;
126 UINT32 Index;
127 INT32 GicItsNode;
128 UINT32 GicItsNodeCount;
129 VOID *Fdt;
130
131 if (FdtParserHandle == NULL) {
132 ASSERT (0);
133 return EFI_INVALID_PARAMETER;
134 }
135
136 Fdt = FdtParserHandle->Fdt;
137
138 if (!FdtNodeHasProperty (Fdt, FdtBranch, "interrupt-controller")) {
139 ASSERT (0);
140 return EFI_INVALID_PARAMETER;
141 }
142
143 // Get the Gic version of the interrupt-controller.
144 Status = GetGicVersion (Fdt, FdtBranch, &GicVersion);
145 if (EFI_ERROR (Status)) {
146 ASSERT (0);
147 return Status;
148 }
149
150 if (GicVersion < 3) {
151 ASSERT (0);
152 return EFI_UNSUPPORTED;
153 }
154
155 // Count the nodes with the "msi-controller" property.
156 // The interrupt-controller itself can have this property,
157 // but the first node is skipped in the search.
158 Status = FdtCountPropNodeInBranch (
159 Fdt,
160 FdtBranch,
161 "msi-controller",
162 &GicItsNodeCount
163 );
164 if (EFI_ERROR (Status)) {
165 ASSERT (0);
166 return Status;
167 }
168
169 if (GicItsNodeCount == 0) {
170 return EFI_NOT_FOUND;
171 }
172
173 GicItsNode = FdtBranch;
174 for (Index = 0; Index < GicItsNodeCount; Index++) {
175 ZeroMem (&GicItsInfo, sizeof (CM_ARM_GIC_ITS_INFO));
176
178 Fdt,
179 FdtBranch,
180 "msi-controller",
181 &GicItsNode
182 );
183 if (EFI_ERROR (Status)) {
184 ASSERT (0);
185 if (Status == EFI_NOT_FOUND) {
186 // Should have found the node.
187 Status = EFI_ABORTED;
188 }
189
190 return Status;
191 }
192
193 Status = GicItsIntcNodeParser (
194 Fdt,
195 GicItsNode,
196 Index,
197 &GicItsInfo
198 );
199 if (EFI_ERROR (Status)) {
200 ASSERT (0);
201 return Status;
202 }
203
204 // Add the CmObj to the Configuration Manager.
205 Status = AddSingleCmObj (
206 FdtParserHandle,
208 &GicItsInfo,
209 sizeof (CM_ARM_GIC_ITS_INFO),
210 NULL
211 );
212 if (EFI_ERROR (Status)) {
213 ASSERT (0);
214 return Status;
215 }
216 } // for
217
218 return Status;
219}
EFI_STATUS EFIAPI GetGicVersion(IN CONST VOID *Fdt, IN INT32 IntcNode, OUT UINT32 *GicVersion)
STATIC EFI_STATUS EFIAPI GicItsIntcNodeParser(IN CONST VOID *Fdt, IN INT32 GicIntcNode, IN UINT32 GicItsId, IN CM_ARM_GIC_ITS_INFO *GicItsInfo)
EFI_STATUS EFIAPI ArmGicItsInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
@ EArmObjGicItsInfo
6 - GIC ITS Info
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EFIAPI AddSingleCmObj(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN CM_OBJECT_ID ObjectId, IN VOID *Data, IN UINT32 Size, OUT CM_OBJECT_TOKEN *Token OPTIONAL)
#define CREATE_CM_ARM_OBJECT_ID(ObjectId)
EFI_STATUS EFIAPI FdtGetNextPropNodeInBranch(IN CONST VOID *Fdt, IN INT32 FdtBranch, IN CONST CHAR8 *PropName, IN OUT INT32 *Node)
Definition: FdtUtility.c:438
EFI_STATUS EFIAPI FdtCountPropNodeInBranch(IN CONST VOID *Fdt, IN INT32 FdtBranch, IN CONST CHAR8 *PropName, OUT UINT32 *NodeCount)
Definition: FdtUtility.c:606
EFI_STATUS EFIAPI FdtGetParentAddressInfo(IN CONST VOID *Fdt, IN INT32 Node, OUT INT32 *AddressCells, OPTIONAL OUT INT32 *SizeCells OPTIONAL)
Definition: FdtUtility.c:833
BOOLEAN EFIAPI FdtNodeHasProperty(IN CONST VOID *Fdt, IN INT32 Node, IN CONST VOID *PropertyName)
Definition: FdtUtility.c:144
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29