TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmGicDParser.c
Go to the documentation of this file.
1
13#include "CmObjectDescUtility.h"
14#include "FdtHwInfoParser.h"
17
34EFIAPI
36 IN CONST VOID *Fdt,
37 IN INT32 GicIntcNode,
38 IN CM_ARM_GICD_INFO *GicDInfo
39 )
40{
41 EFI_STATUS Status;
42 INT32 AddressCells;
43 CONST UINT8 *Data;
44 INT32 DataSize;
45
46 if ((Fdt == NULL) ||
47 (GicDInfo == NULL))
48 {
49 ASSERT (0);
50 return EFI_INVALID_PARAMETER;
51 }
52
53 Status = FdtGetParentAddressInfo (Fdt, GicIntcNode, &AddressCells, NULL);
54 if (EFI_ERROR (Status)) {
55 ASSERT (0);
56 return Status;
57 }
58
59 // Don't support more than 64 bits and less than 32 bits addresses.
60 if ((AddressCells < 1) ||
61 (AddressCells > 2))
62 {
63 ASSERT (0);
64 return EFI_ABORTED;
65 }
66
67 Data = fdt_getprop (Fdt, GicIntcNode, "reg", &DataSize);
68 if ((Data == NULL) || (DataSize < (INT32)(AddressCells * sizeof (UINT32)))) {
69 // If error or not enough space.
70 ASSERT (0);
71 return EFI_ABORTED;
72 }
73
74 if (AddressCells == 2) {
75 GicDInfo->PhysicalBaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
76 } else {
77 GicDInfo->PhysicalBaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
78 }
79
80 return Status;
81}
82
112EFIAPI
114 IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle,
115 IN INT32 FdtBranch
116 )
117{
118 EFI_STATUS Status;
119 UINT32 GicVersion;
120 CM_ARM_GICD_INFO GicDInfo;
121 VOID *Fdt;
122
123 if (FdtParserHandle == NULL) {
124 ASSERT (0);
125 return EFI_INVALID_PARAMETER;
126 }
127
128 Fdt = FdtParserHandle->Fdt;
129
130 if (!FdtNodeHasProperty (Fdt, FdtBranch, "interrupt-controller")) {
131 ASSERT (0);
132 return EFI_INVALID_PARAMETER;
133 }
134
135 // Get the Gic version of the interrupt-controller.
136 Status = GetGicVersion (Fdt, FdtBranch, &GicVersion);
137 if (EFI_ERROR (Status)) {
138 ASSERT (0);
139 return Status;
140 }
141
142 ZeroMem (&GicDInfo, sizeof (GicDInfo));
143 GicDInfo.GicVersion = GicVersion;
144
145 // Parse the interrupt-controller depending on its Gic version.
146 switch (GicVersion) {
147 case 2:
148 case 3:
149 {
150 // Set the Gic version, then parse the GicD information.
151 Status = GicDIntcNodeParser (Fdt, FdtBranch, &GicDInfo);
152 break;
153 }
154 default:
155 {
156 // Unsupported Gic version.
157 ASSERT (0);
158 return EFI_UNSUPPORTED;
159 }
160 }
161
162 // Add the CmObj to the Configuration Manager.
163 Status = AddSingleCmObj (
164 FdtParserHandle,
166 &GicDInfo,
167 sizeof (CM_ARM_GICD_INFO),
168 NULL
169 );
170 ASSERT_EFI_ERROR (Status);
171 return Status;
172}
STATIC EFI_STATUS EFIAPI GicDIntcNodeParser(IN CONST VOID *Fdt, IN INT32 GicIntcNode, IN CM_ARM_GICD_INFO *GicDInfo)
Definition: ArmGicDParser.c:35
EFI_STATUS EFIAPI ArmGicDInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
EFI_STATUS EFIAPI GetGicVersion(IN CONST VOID *Fdt, IN INT32 IntcNode, OUT UINT32 *GicVersion)
@ EArmObjGicDInfo
3 - GIC Distributor 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 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
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29