TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmBootArchParser.c
Go to the documentation of this file.
1
11#include <Library/BaseLib.h>
13#include "FdtHwInfoParser.h"
14#include "CmObjectDescUtility.h"
16
22 { "arm,psci-0.2" },
23 { "arm,psci" }
24};
25
31};
32
36 "smc",
37 "hvc"
38};
39
52EFIAPI
54 IN CONST VOID *Fdt,
55 IN INT32 PsciNode,
56 IN CM_ARM_BOOT_ARCH_INFO *BootArchInfo
57 )
58{
59 CONST VOID *Data;
60 INT32 DataSize;
61
62 if ((Fdt == NULL) ||
63 (BootArchInfo == NULL))
64 {
65 ASSERT (0);
66 return EFI_INVALID_PARAMETER;
67 }
68
69 // Default to parking protocol
70 BootArchInfo->BootArchFlags = 0;
71
72 Data = fdt_getprop (Fdt, PsciNode, "method", &DataSize);
73 if ((Data == NULL) || (DataSize < 0)) {
74 ASSERT (0);
75 return EFI_ABORTED;
76 }
77
78 // Check PSCI conduit.
79 if (AsciiStrnCmp (Data, PsciMethod[0], DataSize) == 0) {
80 BootArchInfo->BootArchFlags = EFI_ACPI_6_3_ARM_PSCI_COMPLIANT;
81 } else if (AsciiStrnCmp (Data, PsciMethod[1], DataSize) == 0) {
82 BootArchInfo->BootArchFlags = (EFI_ACPI_6_3_ARM_PSCI_COMPLIANT |
83 EFI_ACPI_6_3_ARM_PSCI_USE_HVC);
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 PsciNode;
122 CM_ARM_BOOT_ARCH_INFO BootArchInfo;
123
124 if (FdtParserHandle == NULL) {
125 ASSERT (0);
126 return EFI_INVALID_PARAMETER;
127 }
128
129 ZeroMem (&BootArchInfo, sizeof (CM_ARM_BOOT_ARCH_INFO));
130
131 PsciNode = FdtBranch;
133 FdtParserHandle->Fdt,
134 FdtBranch,
136 &PsciNode
137 );
138 if (EFI_ERROR (Status)) {
139 // Error, or no node found.
140 ASSERT (Status == EFI_NOT_FOUND);
141 return Status;
142 }
143
144 // Parse the psci node.
145 Status = PsciNodeParser (FdtParserHandle->Fdt, PsciNode, &BootArchInfo);
146 if (EFI_ERROR (Status)) {
147 ASSERT (0);
148 return Status;
149 }
150
151 // Add the CmObj to the Configuration Manager.
152 Status = AddSingleCmObj (
153 FdtParserHandle,
155 &BootArchInfo,
156 sizeof (CM_ARM_BOOT_ARCH_INFO),
157 NULL
158 );
159 ASSERT_EFI_ERROR (Status);
160 return Status;
161}
EFI_STATUS EFIAPI ArmBootArchInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
STATIC CONST COMPATIBILITY_INFO PsciCompatibleInfo
STATIC EFI_STATUS EFIAPI PsciNodeParser(IN CONST VOID *Fdt, IN INT32 PsciNode, IN CM_ARM_BOOT_ARCH_INFO *BootArchInfo)
STATIC CONST CHAR8 * PsciMethod[]
STATIC CONST COMPATIBILITY_STR PsciCompatibleStr[]
@ EArmObjBootArchInfo
1 - Boot Architecture Info
INTN EFIAPI AsciiStrnCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
Definition: String.c:872
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 FdtGetNextCompatNodeInBranch(IN CONST VOID *Fdt, IN INT32 FdtBranch, IN CONST COMPATIBILITY_INFO *CompatNamesInfo, IN OUT INT32 *Node)
Definition: FdtUtility.c:398
#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 ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112