TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmGicDispatcher.c
Go to the documentation of this file.
1
12#include "FdtHwInfoParser.h"
19
25 { "arm,cortex-a15-gic" }
26};
27
33};
34
40 { "arm,gic-v3" }
41};
42
48};
49
62EFIAPI
64 IN CONST VOID *Fdt,
65 IN INT32 IntcNode,
66 OUT UINT32 *GicVersion
67 )
68{
69 if ((Fdt == NULL) ||
70 (GicVersion == NULL))
71 {
72 ASSERT (0);
73 return EFI_INVALID_PARAMETER;
74 }
75
76 if (FdtNodeIsCompatible (Fdt, IntcNode, &GicV2CompatibleInfo)) {
77 *GicVersion = 2;
78 } else if (FdtNodeIsCompatible (Fdt, IntcNode, &GicV3CompatibleInfo)) {
79 *GicVersion = 3;
80 } else {
81 // Unsupported Gic version.
82 ASSERT (0);
83 return EFI_UNSUPPORTED;
84 }
85
86 return EFI_SUCCESS;
87}
88
114EFIAPI
116 IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle,
117 IN INT32 FdtBranch
118 )
119{
120 EFI_STATUS Status;
121 INT32 CpusNode;
122 INT32 IntcNode;
123 UINT32 GicVersion;
124 VOID *Fdt;
125
126 if (FdtParserHandle == NULL) {
127 ASSERT (0);
128 return EFI_INVALID_PARAMETER;
129 }
130
131 Fdt = FdtParserHandle->Fdt;
132
133 // The "cpus" node resides at the root of the DT. Fetch it.
134 CpusNode = fdt_path_offset (Fdt, "/cpus");
135 if (CpusNode < 0) {
136 return EFI_NOT_FOUND;
137 }
138
139 // Get the interrupt-controller node associated to the "cpus" node.
140 Status = FdtGetIntcParentNode (Fdt, CpusNode, &IntcNode);
141 if (EFI_ERROR (Status)) {
142 ASSERT (0);
143 if (Status == EFI_NOT_FOUND) {
144 // Should have found the node.
145 Status = EFI_ABORTED;
146 }
147
148 return Status;
149 }
150
151 Status = GetGicVersion (Fdt, IntcNode, &GicVersion);
152 if (EFI_ERROR (Status)) {
153 ASSERT (0);
154 return Status;
155 }
156
157 // Parse the GicC information.
158 Status = ArmGicCInfoParser (FdtParserHandle, CpusNode);
159 if (EFI_ERROR (Status)) {
160 // Don't try to parse GicD and GicMsiFrame information
161 // if no GicC information is found. Return.
162 ASSERT (Status == EFI_NOT_FOUND);
163 return Status;
164 }
165
166 // Parse the GicD information of the "cpus" interrupt-controller node.
167 Status = ArmGicDInfoParser (FdtParserHandle, IntcNode);
168 if (EFI_ERROR (Status)) {
169 // EFI_NOT_FOUND is not tolerated at this point.
170 ASSERT (0);
171 return Status;
172 }
173
174 switch (GicVersion) {
175 case 4:
176 case 3:
177 {
178 // Parse the GicR information of the interrupt-controller node.
179 Status = ArmGicRInfoParser (FdtParserHandle, IntcNode);
180 if (EFI_ERROR (Status)) {
181 // EFI_NOT_FOUND is not tolerated at this point.
182 ASSERT (0);
183 return Status;
184 }
185
186 // Parse the GicIts information of the interrupt-controller node.
187 Status = ArmGicItsInfoParser (FdtParserHandle, IntcNode);
188 if (EFI_ERROR (Status) &&
189 (Status != EFI_NOT_FOUND))
190 {
191 ASSERT (0);
192 return Status;
193 }
194
195 break;
196 }
197 case 2:
198 {
199 // Parse the GicMsiFrame information.
200 Status = ArmGicMsiFrameInfoParser (FdtParserHandle, IntcNode);
201 if (EFI_ERROR (Status) &&
202 (Status != EFI_NOT_FOUND))
203 {
204 ASSERT (0);
205 return Status;
206 }
207
208 break;
209 }
210 default:
211 {
212 ASSERT (0);
213 return EFI_UNSUPPORTED;
214 }
215 }
216
217 return EFI_SUCCESS;
218}
EFI_STATUS EFIAPI ArmGicCInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
EFI_STATUS EFIAPI ArmGicDInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
CONST COMPATIBILITY_INFO GicV2CompatibleInfo
STATIC CONST COMPATIBILITY_STR GicV3CompatibleStr[]
EFI_STATUS EFIAPI GetGicVersion(IN CONST VOID *Fdt, IN INT32 IntcNode, OUT UINT32 *GicVersion)
CONST COMPATIBILITY_INFO GicV3CompatibleInfo
EFI_STATUS EFIAPI ArmGicDispatcher(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
STATIC CONST COMPATIBILITY_STR GicV2CompatibleStr[]
EFI_STATUS EFIAPI ArmGicItsInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
EFI_STATUS EFIAPI ArmGicMsiFrameInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
EFI_STATUS EFIAPI ArmGicRInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
BOOLEAN EFIAPI FdtNodeIsCompatible(IN CONST VOID *Fdt, IN INT32 Node, IN CONST VOID *CompatInfo)
Definition: FdtUtility.c:90
EFI_STATUS EFIAPI FdtGetIntcParentNode(IN CONST VOID *Fdt, IN INT32 Node, OUT INT32 *IntcNode)
Definition: FdtUtility.c:650
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define ARRAY_SIZE(Array)
Definition: Base.h:1393
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112