TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmGicMsiFrameParser.c
Go to the documentation of this file.
1
13#include "CmObjectDescUtility.h"
14#include "FdtHwInfoParser.h"
17
23 { "arm,gic-v2m-frame" }
24};
25
31};
32
46EFIAPI
48 IN CONST VOID *Fdt,
49 IN INT32 MsiFrameNode,
50 IN UINT32 MsiFrameId,
51 OUT CM_ARM_GIC_MSI_FRAME_INFO *MsiFrameInfo
52 )
53{
54 EFI_STATUS Status;
55 INT32 AddressCells;
56 CONST UINT8 *Data;
57 INT32 DataSize;
58
59 if ((Fdt == NULL) ||
60 (MsiFrameInfo == NULL))
61 {
62 ASSERT (0);
63 return EFI_INVALID_PARAMETER;
64 }
65
66 Status = FdtGetParentAddressInfo (Fdt, MsiFrameNode, &AddressCells, NULL);
67 if (EFI_ERROR (Status)) {
68 ASSERT (0);
69 return Status;
70 }
71
72 // Don't support more than 64 bits and less than 32 bits addresses.
73 if ((AddressCells < 1) ||
74 (AddressCells > 2))
75 {
76 ASSERT (0);
77 return EFI_ABORTED;
78 }
79
80 Data = fdt_getprop (Fdt, MsiFrameNode, "reg", &DataSize);
81 if ((Data == NULL) || (DataSize < (INT32)(AddressCells * sizeof (UINT32)))) {
82 // If error or not enough space.
83 ASSERT (0);
84 return EFI_ABORTED;
85 }
86
87 if (AddressCells == 2) {
88 MsiFrameInfo->PhysicalBaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
89 } else {
90 MsiFrameInfo->PhysicalBaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
91 }
92
93 MsiFrameInfo->GicMsiFrameId = MsiFrameId;
94
95 return EFI_SUCCESS;
96}
97
127EFIAPI
129 IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle,
130 IN INT32 FdtBranch
131 )
132{
133 EFI_STATUS Status;
134 INT32 MsiFrameNode;
135 UINT32 MsiFrameNodeCount;
136
137 UINT32 Index;
138 CM_ARM_GIC_MSI_FRAME_INFO MsiFrameInfo;
139 VOID *Fdt;
140
141 if (FdtParserHandle == NULL) {
142 ASSERT (0);
143 return EFI_INVALID_PARAMETER;
144 }
145
146 Fdt = FdtParserHandle->Fdt;
147
148 // Count the number of nodes having the "interrupt-controller" property.
149 Status = FdtCountPropNodeInBranch (
150 Fdt,
151 FdtBranch,
152 "msi-controller",
153 &MsiFrameNodeCount
154 );
155 if (EFI_ERROR (Status)) {
156 ASSERT (0);
157 return Status;
158 }
159
160 if (MsiFrameNodeCount == 0) {
161 return EFI_NOT_FOUND;
162 }
163
164 // Parse each node having the "msi-controller" property.
165 MsiFrameNode = FdtBranch;
166 for (Index = 0; Index < MsiFrameNodeCount; Index++) {
167 ZeroMem (&MsiFrameInfo, sizeof (CM_ARM_GIC_MSI_FRAME_INFO));
168
170 Fdt,
171 FdtBranch,
172 "msi-controller",
173 &MsiFrameNode
174 );
175 if (EFI_ERROR (Status)) {
176 ASSERT (0);
177 if (Status == EFI_NOT_FOUND) {
178 // Should have found the node.
179 Status = EFI_ABORTED;
180 }
181
182 return Status;
183 }
184
185 if (!FdtNodeIsCompatible (Fdt, MsiFrameNode, &MsiFrameCompatibleInfo)) {
186 ASSERT (0);
187 Status = EFI_UNSUPPORTED;
188 return Status;
189 }
190
191 // Parse the Msi information.
192 Status = MsiFrameNodeParser (
193 Fdt,
194 MsiFrameNode,
195 Index,
196 &MsiFrameInfo
197 );
198 if (EFI_ERROR (Status)) {
199 ASSERT (0);
200 return Status;
201 }
202
203 // Add the CmObj to the Configuration Manager.
204 Status = AddSingleCmObj (
205 FdtParserHandle,
207 &MsiFrameInfo,
209 NULL
210 );
211 if (EFI_ERROR (Status)) {
212 ASSERT (0);
213 return Status;
214 }
215 } // for
216
217 return Status;
218}
STATIC EFI_STATUS EFIAPI MsiFrameNodeParser(IN CONST VOID *Fdt, IN INT32 MsiFrameNode, IN UINT32 MsiFrameId, OUT CM_ARM_GIC_MSI_FRAME_INFO *MsiFrameInfo)
EFI_STATUS EFIAPI ArmGicMsiFrameInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
STATIC CONST COMPATIBILITY_STR MsiFrameCompatibleStr[]
STATIC CONST COMPATIBILITY_INFO MsiFrameCompatibleInfo
@ EArmObjGicMsiFrameInfo
4 - GIC MSI Frame 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
BOOLEAN EFIAPI FdtNodeIsCompatible(IN CONST VOID *Fdt, IN INT32 Node, IN CONST VOID *CompatInfo)
Definition: FdtUtility.c:90
EFI_STATUS EFIAPI FdtGetParentAddressInfo(IN CONST VOID *Fdt, IN INT32 Node, OUT INT32 *AddressCells, OPTIONAL OUT INT32 *SizeCells OPTIONAL)
Definition: FdtUtility.c:833
#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