TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmSsdtCpuTopologyGenerator.c
Go to the documentation of this file.
1
17#include <Library/AcpiLib.h>
18#include <Library/BaseLib.h>
20#include <Library/DebugLib.h>
22#include <Protocol/AcpiTable.h>
23
24// Module specific include files.
25#include <AcpiTableGenerator.h>
32
34
51 );
52
61 );
62
89EFIAPI
92 IN AML_NODE_HANDLE ParentNode,
93 IN UINT32 AcpiProcessorUid,
94 IN UINT32 CpuName,
95 OUT AML_OBJECT_NODE_HANDLE *EtNodePtr OPTIONAL
96 )
97{
98 EFI_STATUS Status;
100 CHAR8 AslName[AML_NAME_SEG_SIZE + 1];
101
102 ASSERT (Generator != NULL);
103 ASSERT (ParentNode != NULL);
104
105 Status = WriteAslName ('E', CpuName, AslName);
106 if (EFI_ERROR (Status)) {
107 ASSERT (0);
108 return Status;
109 }
110
111 Status = AmlCodeGenDevice (AslName, ParentNode, &EtNode);
112 if (EFI_ERROR (Status)) {
113 ASSERT (0);
114 return Status;
115 }
116
117 Status = AmlCodeGenNameInteger (
118 "_UID",
119 AcpiProcessorUid,
120 EtNode,
121 NULL
122 );
123 if (EFI_ERROR (Status)) {
124 ASSERT (0);
125 return Status;
126 }
127
128 Status = AmlCodeGenNameString (
129 "_HID",
131 EtNode,
132 NULL
133 );
134 if (EFI_ERROR (Status)) {
135 ASSERT (0);
136 return Status;
137 }
138
139 // If requested, return the handle to the EtNode.
140 if (EtNodePtr != NULL) {
141 *EtNodePtr = EtNode;
142 }
143
144 return Status;
145}
146
164STATIC
166EFIAPI
170 IN UINT32 AcpiProcessorUid,
171 IN CM_OBJECT_TOKEN EtToken,
172 IN UINT32 CpuName,
174 )
175{
176 EFI_STATUS Status;
177 CM_ARM_ET_INFO *EtInfo;
178
179 Status = GetEArmObjEtInfo (
180 CfgMgrProtocol,
181 EtToken,
182 &EtInfo,
183 NULL
184 );
185 if (EFI_ERROR (Status)) {
186 ASSERT (0);
187 return Status;
188 }
189
190 // Currently we only support creation of a ETE Node.
191 if (EtInfo->EtType != ArmEtTypeEte) {
192 return EFI_UNSUPPORTED;
193 }
194
195 Status = CreateAmlEtd (
196 Generator,
197 CpuNode,
198 AcpiProcessorUid,
199 CpuName,
200 NULL
201 );
202 ASSERT_EFI_ERROR (Status);
203 return Status;
204}
205
221EFIAPI
225 IN AML_OBJECT_NODE_HANDLE ScopeNode
226 )
227{
228 EFI_STATUS Status;
229 CM_ARM_GICC_INFO *GicCInfo;
230 UINT32 GicCInfoCount;
231 UINT32 Index;
233
234 ASSERT (Generator != NULL);
235 ASSERT (CfgMgrProtocol != NULL);
236 ASSERT (ScopeNode != NULL);
237
238 Status = GetEArmObjGicCInfo (
239 CfgMgrProtocol,
241 &GicCInfo,
242 &GicCInfoCount
243 );
244 if (EFI_ERROR (Status)) {
245 ASSERT (0);
246 return Status;
247 }
248
249 // For each CM_ARM_GICC_INFO object, create an AML node.
250 for (Index = 0; Index < GicCInfoCount; Index++) {
251 Status = CreateAmlCpu (
252 Generator,
253 ScopeNode,
254 GicCInfo[Index].AcpiProcessorUid,
255 Index,
256 &CpuNode
257 );
258 if (EFI_ERROR (Status)) {
259 ASSERT (0);
260 break;
261 }
262
263 // If a CPC info is associated with the
264 // GicCinfo, create an _CPC method returning them.
265 if (GicCInfo[Index].CpcToken != CM_NULL_TOKEN) {
266 Status = CreateAmlCpcNode (Generator, CfgMgrProtocol, GicCInfo[Index].CpcToken, CpuNode);
267 if (EFI_ERROR (Status)) {
268 ASSERT_EFI_ERROR (Status);
269 break;
270 }
271 }
272
273 if (GicCInfo[Index].EtToken != CM_NULL_TOKEN) {
274 Status = CreateAmlEtNode (
275 Generator,
276 CfgMgrProtocol,
277 GicCInfo[Index].AcpiProcessorUid,
278 GicCInfo[Index].EtToken,
279 Index,
280 CpuNode
281 );
282 if (EFI_ERROR (Status)) {
283 ASSERT_EFI_ERROR (Status);
284 return Status;
285 }
286 }
287 } // for
288
289 return Status;
290}
291
314EFIAPI
317 IN CM_OBJECT_TOKEN AcpiIdObjectToken,
318 OUT UINT32 *AcpiProcessorUid,
319 OUT CM_OBJECT_TOKEN *CpcToken,
320 OUT CM_OBJECT_TOKEN *PsdToken
321 )
322{
323 EFI_STATUS Status;
324 CM_ARM_GICC_INFO *GicCInfo;
325
326 Status = GetEArmObjGicCInfo (
327 CfgMgrProtocol,
328 AcpiIdObjectToken,
329 &GicCInfo,
330 NULL
331 );
332 if (EFI_ERROR (Status)) {
333 return Status;
334 }
335
336 if (AcpiProcessorUid != NULL) {
337 *AcpiProcessorUid = GicCInfo->AcpiProcessorUid;
338 }
339
340 if (CpcToken != NULL) {
341 *CpcToken = GicCInfo->CpcToken;
342 }
343
344 if (PsdToken != NULL) {
345 *PsdToken = GicCInfo->PsdToken;
346 }
347
348 return Status;
349}
350
369EFIAPI
373 IN CM_OBJECT_TOKEN AcpiIdObjectToken,
374 IN UINT32 CpuName,
376 )
377{
378 EFI_STATUS Status;
379 CM_ARM_GICC_INFO *GicCInfo;
380
381 Status = GetEArmObjGicCInfo (
382 CfgMgrProtocol,
383 AcpiIdObjectToken,
384 &GicCInfo,
385 NULL
386 );
387 if (EFI_ERROR (Status)) {
388 return Status;
389 }
390
391 // Add an Embedded Trace node if present.
392 if (GicCInfo->EtToken != CM_NULL_TOKEN) {
393 Status = CreateAmlEtNode (
394 Generator,
395 CfgMgrProtocol,
396 GicCInfo->AcpiProcessorUid,
397 GicCInfo->EtToken,
398 CpuName,
399 CpuNode
400 );
401 if (EFI_ERROR (Status)) {
402 ASSERT_EFI_ERROR (Status);
403 return Status;
404 }
405 }
406
407 return Status;
408}
EFI_STATUS EFIAPI AmlCodeGenDevice(IN CONST CHAR8 *NameString, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenNameString(IN CONST CHAR8 *NameString, IN CONST CHAR8 *String, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenNameInteger(IN CONST CHAR8 *NameString, IN UINT64 Integer, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
void * AML_OBJECT_NODE_HANDLE
Definition: AmlLib.h:55
void * AML_NODE_HANDLE
Definition: AmlLib.h:47
@ ArmEtTypeEte
Embedded Trace Extension.
@ EArmObjEtInfo
23 - Embedded Trace Extension/Module Info
@ EArmObjGicCInfo
2 - GIC CPU Interface Info
EFI_STATUS EFIAPI CreateTopologyFromIntC(IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN AML_OBJECT_NODE_HANDLE ScopeNode)
EFI_STATUS EFIAPI GetIntCInfo(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CM_OBJECT_TOKEN AcpiIdObjectToken, OUT UINT32 *AcpiProcessorUid, OUT CM_OBJECT_TOKEN *CpcToken, OUT CM_OBJECT_TOKEN *PsdToken)
EFI_STATUS EFIAPI AddArchAmlCpuInfo(IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CM_OBJECT_TOKEN AcpiIdObjectToken, IN UINT32 CpuName, OUT AML_OBJECT_NODE_HANDLE *CpuNode)
STATIC EFI_STATUS EFIAPI CreateAmlEtNode(IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN UINT32 AcpiProcessorUid, IN CM_OBJECT_TOKEN EtToken, IN UINT32 CpuName, IN AML_OBJECT_NODE_HANDLE *CpuNode)
STATIC EFI_STATUS EFIAPI CreateAmlEtd(IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, IN AML_NODE_HANDLE ParentNode, IN UINT32 AcpiProcessorUid, IN UINT32 CpuName, OUT AML_OBJECT_NODE_HANDLE *EtNodePtr OPTIONAL)
#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)
@ EObjNameSpaceArm
ARM Objects Namespace.
#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 OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
EFI_STATUS EFIAPI CreateAmlCpu(IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, IN AML_NODE_HANDLE ParentNode, IN UINT32 AcpiProcessorUid, IN UINT32 CpuName, OUT AML_OBJECT_NODE_HANDLE *CpuNodePtr OPTIONAL)
EFI_STATUS EFIAPI WriteAslName(IN CHAR8 LeadChar, IN UINT32 Value, IN OUT CHAR8 *AslName)
EFI_STATUS EFIAPI CreateAmlCpcNode(IN ACPI_CPU_TOPOLOGY_GENERATOR *Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CM_OBJECT_TOKEN CpcToken, IN AML_OBJECT_NODE_HANDLE *Node)
#define ACPI_HID_ET_DEVICE
HID for a ETM/ETE device.
UINTN CM_OBJECT_TOKEN
#define CM_NULL_TOKEN
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
CM_OBJECT_TOKEN PsdToken
CM_OBJECT_TOKEN EtToken
CM_OBJECT_TOKEN CpcToken