]> git.proxmox.com Git - mirror_edk2.git/blob - DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
DynamicTablesPkg: Fix wrong/missing fields in CmObjParser
[mirror_edk2.git] / DynamicTablesPkg / Library / Common / TableHelperLib / ConfigurationManagerObjectParser.c
1 /** @file
2 Configuration Manager Object parser.
3
4 Copyright (c) 2021 - 2022, ARM Limited. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <Library/BaseLib.h>
10 #include <Library/DebugLib.h>
11 #include <ConfigurationManagerObject.h>
12 #include "ConfigurationManagerObjectParser.h"
13
14 STATIC
15 VOID
16 EFIAPI
17 PrintOemId (
18 CONST CHAR8 *Format,
19 UINT8 *Ptr
20 );
21
22 STATIC
23 VOID
24 EFIAPI
25 PrintString (
26 CONST CHAR8 *Format,
27 UINT8 *Ptr
28 );
29
30 /** A parser for EArmObjBootArchInfo.
31 */
32 STATIC CONST CM_OBJ_PARSER CmArmBootArchInfoParser[] = {
33 { "BootArchFlags", 2, "0x%x", NULL }
34 };
35
36 /** A parser for EArmObjPowerManagementProfileInfo.
37 */
38 STATIC CONST CM_OBJ_PARSER CmArmPowerManagementProfileInfoParser[] = {
39 { "PowerManagementProfile", 1, "0x%x", NULL }
40 };
41
42 /** A parser for EArmObjGicCInfo.
43 */
44 STATIC CONST CM_OBJ_PARSER CmArmGicCInfoParser[] = {
45 { "CPUInterfaceNumber", 4, "0x%x", NULL },
46 { "AcpiProcessorUid", 4, "0x%x", NULL },
47 { "Flags", 4, "0x%x", NULL },
48 { "ParkingProtocolVersion", 4, "0x%x", NULL },
49 { "PerformanceInterruptGsiv", 4, "0x%x", NULL },
50 { "ParkedAddress", 8, "0x%llx", NULL },
51 { "PhysicalBaseAddress", 8, "0x%llx", NULL },
52 { "GICV", 8, "0x%llx", NULL },
53 { "GICH", 8, "0x%llx", NULL },
54 { "VGICMaintenanceInterrupt", 4, "0x%x", NULL },
55 { "GICRBaseAddress", 8, "0x%llx", NULL },
56 { "MPIDR", 8, "0x%llx", NULL },
57 { "ProcessorPowerEfficiencyClass", 1, "0x%x", NULL },
58 { "SpeOverflowInterrupt", 2, "0x%x", NULL },
59 { "ProximityDomain", 4, "0x%x", NULL },
60 { "ClockDomain", 4, "0x%x", NULL },
61 { "AffinityFlags", 4, "0x%x", NULL },
62 { "CpcToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }
63 };
64
65 /** A parser for EArmObjGicDInfo.
66 */
67 STATIC CONST CM_OBJ_PARSER CmArmGicDInfoParser[] = {
68 { "PhysicalBaseAddress", 8, "0x%llx", NULL },
69 { "SystemVectorBase", 4, "0x%x", NULL },
70 { "GicVersion", 1, "0x%x", NULL },
71 };
72
73 /** A parser for EArmObjGicMsiFrameInfo.
74 */
75 STATIC CONST CM_OBJ_PARSER CmArmGicMsiFrameInfoParser[] = {
76 { "GicMsiFrameId", 4, "0x%x", NULL },
77 { "PhysicalBaseAddress", 8, "0x%llx", NULL },
78 { "Flags", 4, "0x%x", NULL },
79 { "SPICount", 2, "0x%x", NULL },
80 { "SPIBase", 2, "0x%x", NULL }
81 };
82
83 /** A parser for EArmObjGicRedistributorInfo.
84 */
85 STATIC CONST CM_OBJ_PARSER CmArmGicRedistInfoParser[] = {
86 { "DiscoveryRangeBaseAddress", 8, "0x%llx", NULL },
87 { "DiscoveryRangeLength", 4, "0x%x", NULL }
88 };
89
90 /** A parser for EArmObjGicItsInfo.
91 */
92 STATIC CONST CM_OBJ_PARSER CmArmGicItsInfoParser[] = {
93 { "GicItsId", 4, "0x%x", NULL },
94 { "PhysicalBaseAddress", 8, "0x%llx", NULL },
95 { "ProximityDomain", 4, "0x%x", NULL }
96 };
97
98 /** A parser for EArmObjSerialConsolePortInfo,
99 EArmObjSerialDebugPortInfo and EArmObjSerialPortInfo.
100 */
101 STATIC CONST CM_OBJ_PARSER CmArmSerialPortInfoParser[] = {
102 { "BaseAddress", 8, "0x%llx", NULL },
103 { "Interrupt", 4, "0x%x", NULL },
104 { "BaudRate", 8, "0x%llx", NULL },
105 { "Clock", 4, "0x%x", NULL },
106 { "PortSubtype", 2, "0x%x", NULL },
107 { "BaseAddressLength", 8, "0x%llx", NULL },
108 { "AccessSize", 1, "0x%d", NULL }
109 };
110
111 /** A parser for EArmObjGenericTimerInfo.
112 */
113 STATIC CONST CM_OBJ_PARSER CmArmGenericTimerInfoParser[] = {
114 { "CounterControlBaseAddress", 8, "0x%llx", NULL },
115 { "CounterReadBaseAddress", 8, "0x%llx", NULL },
116 { "SecurePL1TimerGSIV", 4, "0x%x", NULL },
117 { "SecurePL1TimerFlags", 4, "0x%x", NULL },
118 { "NonSecurePL1TimerGSIV", 4, "0x%x", NULL },
119 { "NonSecurePL1TimerFlags", 4, "0x%x", NULL },
120 { "VirtualTimerGSIV", 4, "0x%x", NULL },
121 { "VirtualTimerFlags", 4, "0x%x", NULL },
122 { "NonSecurePL2TimerGSIV", 4, "0x%x", NULL },
123 { "NonSecurePL2TimerFlags", 4, "0x%x", NULL },
124 { "VirtualPL2TimerGSIV", 4, "0x%x", NULL },
125 { "VirtualPL2TimerFlags", 4, "0x%x", NULL }
126 };
127
128 /** A parser for EArmObjPlatformGTBlockInfo.
129 */
130 STATIC CONST CM_OBJ_PARSER CmArmGTBlockInfoParser[] = {
131 { "GTBlockPhysicalAddress", 8, "0x%llx", NULL },
132 { "GTBlockTimerFrameCount", 4, "0x%x", NULL },
133 { "GTBlockTimerFrameToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }
134 };
135
136 /** A parser for EArmObjGTBlockTimerFrameInfo.
137 */
138 STATIC CONST CM_OBJ_PARSER CmArmGTBlockTimerFrameInfoParser[] = {
139 { "FrameNumber", 1, "0x%x", NULL },
140 { "PhysicalAddressCntBase", 8, "0x%llx", NULL },
141 { "PhysicalAddressCntEL0Base", 8, "0x%llx", NULL },
142 { "PhysicalTimerGSIV", 4, "0x%x", NULL },
143 { "PhysicalTimerFlags", 4, "0x%x", NULL },
144 { "VirtualTimerGSIV", 4, "0x%x", NULL },
145 { "VirtualTimerFlags", 4, "0x%x", NULL },
146 { "CommonFlags", 4, "0x%x", NULL }
147 };
148
149 /** A parser for EArmObjPlatformGenericWatchdogInfo.
150 */
151 STATIC CONST CM_OBJ_PARSER CmArmGenericWatchdogInfoParser[] = {
152 { "ControlFrameAddress", 8, "0x%llx", NULL },
153 { "RefreshFrameAddress", 8, "0x%llx", NULL },
154 { "TimerGSIV", 4, "0x%x", NULL },
155 { "Flags", 4, "0x%x", NULL }
156 };
157
158 /** A parser for EArmObjPciConfigSpaceInfo.
159 */
160 STATIC CONST CM_OBJ_PARSER CmArmPciConfigSpaceInfoParser[] = {
161 { "BaseAddress", 8, "0x%llx", NULL },
162 { "PciSegmentGroupNumber", 2, "0x%x", NULL },
163 { "StartBusNumber", 1, "0x%x", NULL },
164 { "EndBusNumber", 1, "0x%x", NULL },
165 { "AddressMapToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
166 { "InterruptMapToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
167 };
168
169 /** A parser for EArmObjHypervisorVendorIdentity.
170 */
171 STATIC CONST CM_OBJ_PARSER CmArmHypervisorVendorIdParser[] = {
172 { "HypervisorVendorId", 8, "0x%llx", NULL }
173 };
174
175 /** A parser for EArmObjFixedFeatureFlags.
176 */
177 STATIC CONST CM_OBJ_PARSER CmArmFixedFeatureFlagsParser[] = {
178 { "Flags", 4, "0x%x", NULL }
179 };
180
181 /** A parser for EArmObjItsGroup.
182 */
183 STATIC CONST CM_OBJ_PARSER CmArmItsGroupNodeParser[] = {
184 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
185 { "ItsIdCount", 4, "0x%x", NULL },
186 { "ItsIdToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
187 { "Identifier", 4, "0x%x", NULL },
188 };
189
190 /** A parser for EArmObjNamedComponent.
191 */
192 STATIC CONST CM_OBJ_PARSER CmArmNamedComponentNodeParser[] = {
193 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
194 { "IdMappingCount", 4, "0x%x", NULL },
195 { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
196 { "Flags", 4, "0x%x", NULL },
197 { "CacheCoherent", 4, "0x%x", NULL },
198 { "AllocationHints", 1, "0x%x", NULL },
199 { "MemoryAccessFlags", 1, "0x%x", NULL },
200 { "AddressSizeLimit", 1, "0x%x", NULL },
201 { "ObjectName", sizeof (CHAR8 *), NULL, PrintString },
202 { "Identifier", 4, "0x%x", NULL },
203 };
204
205 /** A parser for EArmObjRootComplex.
206 */
207 STATIC CONST CM_OBJ_PARSER CmArmRootComplexNodeParser[] = {
208 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
209 { "IdMappingCount", 4, "0x%x", NULL },
210 { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
211 { "CacheCoherent", 4, "0x%x", NULL },
212 { "AllocationHints", 1, "0x%x", NULL },
213 { "MemoryAccessFlags", 1, "0x%x", NULL },
214 { "AtsAttribute", 4, "0x%x", NULL },
215 { "PciSegmentNumber", 4, "0x%x", NULL },
216 { "MemoryAddressSize", 1, "0x%x", NULL },
217 { "PasidCapabilities", 2, "0x%x", NULL },
218 { "Flags", 4, "0x%x", NULL },
219 { "Identifier", 4, "0x%x", NULL },
220 };
221
222 /** A parser for EArmObjSmmuV1SmmuV2.
223 */
224 STATIC CONST CM_OBJ_PARSER CmArmSmmuV1SmmuV2NodeParser[] = {
225 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
226 { "IdMappingCount", 4, "0x%x", NULL },
227 { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
228 { "BaseAddress", 8, "0x%llx", NULL },
229 { "Span", 8, "0x%llx", NULL },
230 { "Model", 4, "0x%x", NULL },
231 { "Flags", 4, "0x%x", NULL },
232 { "ContextInterruptCount", 4, "0x%x", NULL },
233 { "ContextInterruptToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
234 { "PmuInterruptCount", 4, "0x%x", NULL },
235 { "PmuInterruptToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
236 { "SMMU_NSgIrpt", 4, "0x%x", NULL },
237 { "SMMU_NSgIrptFlags", 4, "0x%x", NULL },
238 { "SMMU_NSgCfgIrpt", 4, "0x%x", NULL },
239 { "SMMU_NSgCfgIrptFlags", 4, "0x%x", NULL },
240 { "Identifier", 4, "0x%x", NULL },
241 };
242
243 /** A parser for EArmObjSmmuV3.
244 */
245 STATIC CONST CM_OBJ_PARSER CmArmSmmuV3NodeParser[] = {
246 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
247 { "IdMappingCount", 4, "0x%x", NULL },
248 { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
249 { "BaseAddress", 8, "0x%llx", NULL },
250 { "Flags", 4, "0x%x", NULL },
251 { "VatosAddress", 8, "0x%llx", NULL },
252 { "Model", 4, "0x%x", NULL },
253 { "EventInterrupt", 4, "0x%x", NULL },
254 { "PriInterrupt", 4, "0x%x", NULL },
255 { "GerrInterrupt", 4, "0x%x", NULL },
256 { "SyncInterrupt", 4, "0x%x", NULL },
257 { "ProximityDomain", 4, "0x%x", NULL },
258 { "DeviceIdMappingIndex", 4, "0x%x", NULL },
259 { "Identifier", 4, "0x%x", NULL },
260 };
261
262 /** A parser for EArmObjPmcg.
263 */
264 STATIC CONST CM_OBJ_PARSER CmArmPmcgNodeParser[] = {
265 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
266 { "IdMappingCount", 4, "0x%x", NULL },
267 { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
268 { "BaseAddress", 8, "0x%llx", NULL },
269 { "OverflowInterrupt", 4, "0x%x", NULL },
270 { "Page1BaseAddress", 8, "0x%llx", NULL },
271 { "ReferenceToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
272 { "Identifier", 4, "0x%x", NULL },
273 };
274
275 /** A parser for EArmObjGicItsIdentifierArray.
276 */
277 STATIC CONST CM_OBJ_PARSER CmArmGicItsIdentifierParser[] = {
278 { "ItsId", 4, "0x%x", NULL }
279 };
280
281 /** A parser for EArmObjIdMappingArray.
282 */
283 STATIC CONST CM_OBJ_PARSER CmArmIdMappingParser[] = {
284 { "InputBase", 4, "0x%x", NULL },
285 { "NumIds", 4, "0x%x", NULL },
286 { "OutputBase", 4, "0x%x", NULL },
287 { "OutputReferenceToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
288 { "Flags", 4, "0x%x", NULL }
289 };
290
291 /** A parser for EArmObjSmmuInterruptArray.
292 */
293 STATIC CONST CM_OBJ_PARSER CmArmGenericInterruptParser[] = {
294 { "Interrupt", 4, "0x%x", NULL },
295 { "Flags", 4, "0x%x", NULL }
296 };
297
298 /** A parser for EArmObjProcHierarchyInfo.
299 */
300 STATIC CONST CM_OBJ_PARSER CmArmProcHierarchyInfoParser[] = {
301 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
302 { "Flags", 4, "0x%x", NULL },
303 { "ParentToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
304 { "GicCToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
305 { "NoOfPrivateResources", 4, "0x%x", NULL },
306 { "PrivateResourcesArrayToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
307 { "LpiToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
308 };
309
310 /** A parser for EArmObjCacheInfo.
311 */
312 STATIC CONST CM_OBJ_PARSER CmArmCacheInfoParser[] = {
313 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
314 { "NextLevelOfCacheToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
315 { "Size", 4, "0x%x", NULL },
316 { "NumberOfSets", 4, "0x%x", NULL },
317 { "Associativity", 4, "0x%x", NULL },
318 { "Attributes", 1, "0x%x", NULL },
319 { "LineSize", 2, "0x%x", NULL },
320 { "CacheId", 4, "0x%x", NULL },
321 };
322
323 /** A parser for EArmObjProcNodeIdInfo.
324 */
325 STATIC CONST CM_OBJ_PARSER CmArmProcNodeIdInfoParser[] = {
326 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
327 { "VendorId", 4, "0x%p", NULL },
328 { "Level1Id", 8, "0x%x", NULL },
329 { "Level2Id", 8, "0x%x", NULL },
330 { "MajorRev", 2, "0x%x", NULL },
331 { "MinorRev", 2, "0x%x", NULL },
332 { "SpinRev", 2, "0x%x", NULL }
333 };
334
335 /** A parser for EArmObjCmRef.
336 */
337 STATIC CONST CM_OBJ_PARSER CmArmObjRefParser[] = {
338 { "ReferenceToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }
339 };
340
341 /** A parser for EArmObjMemoryAffinityInfo.
342 */
343 STATIC CONST CM_OBJ_PARSER CmArmMemoryAffinityInfoParser[] = {
344 { "ProximityDomain", 4, "0x%x", NULL },
345 { "BaseAddress", 8, "0x%llx", NULL },
346 { "Length", 8, "0x%llx", NULL },
347 { "Flags", 4, "0x%x", NULL }
348 };
349
350 /** A parser for EArmObjDeviceHandleAcpi.
351 */
352 STATIC CONST CM_OBJ_PARSER CmArmDeviceHandleAcpiParser[] = {
353 { "Hid", 8, "0x%llx", NULL },
354 { "Uid", 4, "0x%x", NULL }
355 };
356
357 /** A parser for EArmObjDeviceHandlePci.
358 */
359 STATIC CONST CM_OBJ_PARSER CmArmDeviceHandlePciParser[] = {
360 { "SegmentNumber", 2, "0x%x", NULL },
361 { "BusNumber", 1, "0x%x", NULL },
362 { "DeviceNumber", 1, "0x%x", NULL },
363 { "FunctionNumber", 1, "0x%x", NULL }
364 };
365
366 /** A parser for EArmObjGenericInitiatorAffinityInfo.
367 */
368 STATIC CONST CM_OBJ_PARSER CmArmGenericInitiatorAffinityInfoParser[] = {
369 { "ProximityDomain", 4, "0x%x", NULL },
370 { "Flags", 4, "0x%x", NULL },
371 { "DeviceHandleType", 1, "0x%x", NULL },
372 { "DeviceHandleToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }
373 };
374
375 /** A parser for EArmObjCmn600Info.
376 */
377 STATIC CONST CM_OBJ_PARSER CmArmCmn600InfoParser[] = {
378 { "PeriphBaseAddress", 8, "0x%llx", NULL },
379 { "PeriphBaseAddressLength", 8, "0x%llx", NULL },
380 { "RootNodeBaseAddress", 8, "0x%llx", NULL },
381 { "DtcCount", 1, "0x%x", NULL },
382 { "DtcInterrupt[0]", 4, "0x%x", NULL },
383 { "DtcFlags[0]", 4, "0x%x", NULL },
384 { "DtcInterrupt[1]", 4, "0x%x", NULL },
385 { "DtcFlags[1]", 4, "0x%x", NULL },
386 { "DtcInterrupt[2]", 4, "0x%x", NULL },
387 { "DtcFlags[2]", 4, "0x%x", NULL },
388 { "DtcInterrupt[3]", 4, "0x%x", NULL },
389 { "DtcFlags[3]", 4, "0x%x", NULL }
390 };
391
392 /** A parser for the EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE structure.
393 */
394 STATIC CONST CM_OBJ_PARSER AcpiGenericAddressParser[] = {
395 { "AddressSpaceId", 1, "%d", NULL },
396 { "RegisterBitWidth", 1, "%d", NULL },
397 { "RegisterBitOffset", 1, "%d", NULL },
398 { "AccessSize", 1, "%d", NULL },
399 { "Address", 8, "0x%llx", NULL },
400 };
401
402 /** A parser for EArmObjLpiInfo.
403 */
404 STATIC CONST CM_OBJ_PARSER CmArmLpiInfoParser[] = {
405 { "MinResidency", 4, "0x%x", NULL },
406 { "WorstCaseWakeLatency", 4, "0x%x", NULL },
407 { "Flags", 4, "0x%x", NULL },
408 { "ArchFlags", 4, "0x%x", NULL },
409 { "ResCntFreq", 4, "0x%x", NULL },
410 { "EnableParentState", 4, "0x%x", NULL },
411 { "IsInteger", 1, "%d", NULL },
412 { "IntegerEntryMethod", 8, "0x%llx", NULL },
413 { "RegisterEntryMethod", sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE),
414 NULL, NULL, AcpiGenericAddressParser,
415 ARRAY_SIZE (AcpiGenericAddressParser) },
416 { "ResidencyCounterRegister", sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE),
417 NULL, NULL, AcpiGenericAddressParser,
418 ARRAY_SIZE (AcpiGenericAddressParser) },
419 { "UsageCounterRegister", sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE),
420 NULL, NULL, AcpiGenericAddressParser,
421 ARRAY_SIZE (AcpiGenericAddressParser) },
422 { "StateName", 16, NULL, PrintString },
423 };
424
425 /** A parser for EArmObjPciAddressMapInfo.
426 */
427 STATIC CONST CM_OBJ_PARSER CmArmPciAddressMapInfoParser[] = {
428 { "SpaceCode", 1, "%d", NULL },
429 { "PciAddress", 8, "0x%llx", NULL },
430 { "CpuAddress", 8, "0x%llx", NULL },
431 { "AddressSize", 8, "0x%llx", NULL },
432 };
433
434 /** A parser for EArmObjPciInterruptMapInfo.
435 */
436 STATIC CONST CM_OBJ_PARSER CmPciInterruptMapInfoParser[] = {
437 { "PciBus", 1, "0x%x", NULL },
438 { "PciDevice", 1, "0x%x", NULL },
439 { "PciInterrupt", 1, "0x%x", NULL },
440 { "IntcInterrupt", sizeof (CM_ARM_GENERIC_INTERRUPT),
441 NULL, NULL, CmArmGenericInterruptParser,
442 ARRAY_SIZE (CmArmGenericInterruptParser) },
443 };
444
445 /** A parser for EArmObjRmr.
446 */
447 STATIC CONST CM_OBJ_PARSER CmArmRmrInfoParser[] = {
448 { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
449 { "IdMappingCount", 4, "0x%x", NULL },
450 { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
451 { "Identifier", 4, "0x%x", NULL },
452 { "Flags", 4, "0x%x", NULL },
453 { "MemRangeDescCount", 4, "0x%x", NULL },
454 { "MemRangeDescToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
455 };
456
457 /** A parser for EArmObjMemoryRangeDescriptor.
458 */
459 STATIC CONST CM_OBJ_PARSER CmArmMemoryRangeDescriptorInfoParser[] = {
460 { "BaseAddress", 8, "0x%llx", NULL },
461 { "Length", 8, "0x%llx", NULL },
462 };
463
464 /** A parser for EArmObjCpcInfo.
465 */
466 STATIC CONST CM_OBJ_PARSER CmArmCpcInfoParser[] = {
467 { "Revision", 4, "0x%lx", NULL },
468 { "HighestPerformanceBuffer", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
469 NULL, NULL, AcpiGenericAddressParser,
470 ARRAY_SIZE (AcpiGenericAddressParser) },
471 { "HighestPerformanceInteger", 4, "0x%lx", NULL },
472 { "NominalPerformanceBuffer", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
473 NULL, NULL, AcpiGenericAddressParser,
474 ARRAY_SIZE (AcpiGenericAddressParser) },
475 { "NominalPerformanceInteger", 4, "0x%lx", NULL },
476 { "LowestNonlinearPerformanceBuffer", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
477 NULL, NULL, AcpiGenericAddressParser,
478 ARRAY_SIZE (AcpiGenericAddressParser) },
479 { "LowestNonlinearPerformanceInteger", 4, "0x%lx", NULL },
480 { "LowestPerformanceBuffer", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
481 NULL, NULL, AcpiGenericAddressParser,
482 ARRAY_SIZE (AcpiGenericAddressParser) },
483 { "LowestPerformanceInteger", 4, "0x%lx", NULL },
484 { "GuaranteedPerformanceRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
485 NULL, NULL, AcpiGenericAddressParser,
486 ARRAY_SIZE (AcpiGenericAddressParser) },
487 { "DesiredPerformanceRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
488 NULL, NULL, AcpiGenericAddressParser,
489 ARRAY_SIZE (AcpiGenericAddressParser) },
490 { "MinimumPerformanceRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
491 NULL, NULL, AcpiGenericAddressParser,
492 ARRAY_SIZE (AcpiGenericAddressParser) },
493 { "MaximumPerformanceRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
494 NULL, NULL, AcpiGenericAddressParser,
495 ARRAY_SIZE (AcpiGenericAddressParser) },
496 { "PerformanceReductionToleranceRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
497 NULL, NULL, AcpiGenericAddressParser,
498 ARRAY_SIZE (AcpiGenericAddressParser) },
499 { "TimeWindowRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
500 NULL, NULL, AcpiGenericAddressParser,
501 ARRAY_SIZE (AcpiGenericAddressParser) },
502 { "CounterWraparoundTimeBuffer", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
503 NULL, NULL, AcpiGenericAddressParser,
504 ARRAY_SIZE (AcpiGenericAddressParser) },
505 { "CounterWraparoundTimeInteger", 4, "0x%lx", NULL },
506 { "ReferencePerformanceCounterRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
507 NULL, NULL, AcpiGenericAddressParser,
508 ARRAY_SIZE (AcpiGenericAddressParser) },
509 { "DeliveredPerformanceCounterRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
510 NULL, NULL, AcpiGenericAddressParser,
511 ARRAY_SIZE (AcpiGenericAddressParser) },
512 { "PerformanceLimitedRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
513 NULL, NULL, AcpiGenericAddressParser,
514 ARRAY_SIZE (AcpiGenericAddressParser) },
515 { "CPPCEnableRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
516 NULL, NULL, AcpiGenericAddressParser,
517 ARRAY_SIZE (AcpiGenericAddressParser) },
518 { "AutonomousSelectionEnableBuffer", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
519 NULL, NULL, AcpiGenericAddressParser,
520 ARRAY_SIZE (AcpiGenericAddressParser) },
521 { "AutonomousSelectionEnableInteger", 4, "0x%lx", NULL },
522 { "AutonomousActivityWindowRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
523 NULL, NULL, AcpiGenericAddressParser,
524 ARRAY_SIZE (AcpiGenericAddressParser) },
525 { "EnergyPerformancePreferenceRegister", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
526 NULL, NULL, AcpiGenericAddressParser,
527 ARRAY_SIZE (AcpiGenericAddressParser) },
528 { "ReferencePerformanceBuffer", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
529 NULL, NULL, AcpiGenericAddressParser,
530 ARRAY_SIZE (AcpiGenericAddressParser) },
531 { "ReferencePerformanceInteger", 4, "0x%lx", NULL },
532 { "LowestFrequencyBuffer", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
533 NULL, NULL, AcpiGenericAddressParser,
534 ARRAY_SIZE (AcpiGenericAddressParser) },
535 { "LowestFrequencyInteger", 4, "0x%lx", NULL },
536 { "NominalFrequencyBuffer", sizeof (EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE),
537 NULL, NULL, AcpiGenericAddressParser,
538 ARRAY_SIZE (AcpiGenericAddressParser) },
539 { "NominalFrequencyInteger", 4, "0x%lx", NULL },
540 };
541
542 /** A parser for Arm namespace objects.
543 */
544 STATIC CONST CM_OBJ_PARSER_ARRAY ArmNamespaceObjectParser[] = {
545 { "EArmObjReserved", NULL, 0 },
546 { "EArmObjBootArchInfo", CmArmBootArchInfoParser,
547 ARRAY_SIZE (CmArmBootArchInfoParser) },
548 { "EArmObjCpuInfo", NULL, 0 },
549 { "EArmObjPowerManagementProfileInfo", CmArmPowerManagementProfileInfoParser,
550 ARRAY_SIZE (CmArmPowerManagementProfileInfoParser) },
551 { "EArmObjGicCInfo", CmArmGicCInfoParser, ARRAY_SIZE (CmArmGicCInfoParser) },
552 { "EArmObjGicDInfo", CmArmGicDInfoParser, ARRAY_SIZE (CmArmGicDInfoParser) },
553 { "EArmObjGicMsiFrameInfo", CmArmGicMsiFrameInfoParser,
554 ARRAY_SIZE (CmArmGicMsiFrameInfoParser) },
555 { "EArmObjGicRedistributorInfo", CmArmGicRedistInfoParser,
556 ARRAY_SIZE (CmArmGicRedistInfoParser) },
557 { "EArmObjGicItsInfo", CmArmGicItsInfoParser,
558 ARRAY_SIZE (CmArmGicItsInfoParser) },
559 { "EArmObjSerialConsolePortInfo", CmArmSerialPortInfoParser,
560 ARRAY_SIZE (CmArmSerialPortInfoParser) },
561 { "EArmObjSerialDebugPortInfo", CmArmSerialPortInfoParser,
562 ARRAY_SIZE (CmArmSerialPortInfoParser) },
563 { "EArmObjGenericTimerInfo", CmArmGenericTimerInfoParser,
564 ARRAY_SIZE (CmArmGenericTimerInfoParser) },
565 { "EArmObjPlatformGTBlockInfo", CmArmGTBlockInfoParser,
566 ARRAY_SIZE (CmArmGTBlockInfoParser) },
567 { "EArmObjGTBlockTimerFrameInfo", CmArmGTBlockTimerFrameInfoParser,
568 ARRAY_SIZE (CmArmGTBlockTimerFrameInfoParser) },
569 { "EArmObjPlatformGenericWatchdogInfo", CmArmGenericWatchdogInfoParser,
570 ARRAY_SIZE (CmArmGenericWatchdogInfoParser) },
571 { "EArmObjPciConfigSpaceInfo", CmArmPciConfigSpaceInfoParser,
572 ARRAY_SIZE (CmArmPciConfigSpaceInfoParser) },
573 { "EArmObjHypervisorVendorIdentity", CmArmHypervisorVendorIdParser,
574 ARRAY_SIZE (CmArmHypervisorVendorIdParser) },
575 { "EArmObjFixedFeatureFlags", CmArmFixedFeatureFlagsParser,
576 ARRAY_SIZE (CmArmFixedFeatureFlagsParser) },
577 { "EArmObjItsGroup", CmArmItsGroupNodeParser,
578 ARRAY_SIZE (CmArmItsGroupNodeParser) },
579 { "EArmObjNamedComponent", CmArmNamedComponentNodeParser,
580 ARRAY_SIZE (CmArmNamedComponentNodeParser) },
581 { "EArmObjRootComplex", CmArmRootComplexNodeParser,
582 ARRAY_SIZE (CmArmRootComplexNodeParser) },
583 { "EArmObjSmmuV1SmmuV2", CmArmSmmuV1SmmuV2NodeParser,
584 ARRAY_SIZE (CmArmSmmuV1SmmuV2NodeParser) },
585 { "EArmObjSmmuV3", CmArmSmmuV3NodeParser,
586 ARRAY_SIZE (CmArmSmmuV3NodeParser) },
587 { "EArmObjPmcg", CmArmPmcgNodeParser, ARRAY_SIZE (CmArmPmcgNodeParser) },
588 { "EArmObjGicItsIdentifierArray", CmArmGicItsIdentifierParser,
589 ARRAY_SIZE (CmArmGicItsIdentifierParser) },
590 { "EArmObjIdMappingArray", CmArmIdMappingParser,
591 ARRAY_SIZE (CmArmIdMappingParser) },
592 { "EArmObjSmmuInterruptArray", CmArmGenericInterruptParser,
593 ARRAY_SIZE (CmArmGenericInterruptParser) },
594 { "EArmObjProcHierarchyInfo", CmArmProcHierarchyInfoParser,
595 ARRAY_SIZE (CmArmProcHierarchyInfoParser) },
596 { "EArmObjCacheInfo", CmArmCacheInfoParser,
597 ARRAY_SIZE (CmArmCacheInfoParser) },
598 { "EArmObjProcNodeIdInfo", CmArmProcNodeIdInfoParser,
599 ARRAY_SIZE (CmArmProcNodeIdInfoParser) },
600 { "EArmObjCmRef", CmArmObjRefParser, ARRAY_SIZE (CmArmObjRefParser) },
601 { "EArmObjMemoryAffinityInfo", CmArmMemoryAffinityInfoParser,
602 ARRAY_SIZE (CmArmMemoryAffinityInfoParser) },
603 { "EArmObjDeviceHandleAcpi", CmArmDeviceHandleAcpiParser,
604 ARRAY_SIZE (CmArmDeviceHandleAcpiParser) },
605 { "EArmObjDeviceHandlePci", CmArmDeviceHandlePciParser,
606 ARRAY_SIZE (CmArmDeviceHandlePciParser) },
607 { "EArmObjGenericInitiatorAffinityInfo",
608 CmArmGenericInitiatorAffinityInfoParser,
609 ARRAY_SIZE (CmArmGenericInitiatorAffinityInfoParser) },
610 { "EArmObjSerialPortInfo", CmArmSerialPortInfoParser,
611 ARRAY_SIZE (CmArmSerialPortInfoParser) },
612 { "EArmObjCmn600Info", CmArmCmn600InfoParser,
613 ARRAY_SIZE (CmArmCmn600InfoParser) },
614 { "EArmObjLpiInfo", CmArmLpiInfoParser,
615 ARRAY_SIZE (CmArmLpiInfoParser) },
616 { "EArmObjPciAddressMapInfo", CmArmPciAddressMapInfoParser,
617 ARRAY_SIZE (CmArmPciAddressMapInfoParser) },
618 { "EArmObjPciInterruptMapInfo", CmPciInterruptMapInfoParser,
619 ARRAY_SIZE (CmPciInterruptMapInfoParser) },
620 { "EArmObjRmr", CmArmRmrInfoParser,
621 ARRAY_SIZE (CmArmRmrInfoParser) },
622 { "EArmObjMemoryRangeDescriptor", CmArmMemoryRangeDescriptorInfoParser,
623 ARRAY_SIZE (CmArmMemoryRangeDescriptorInfoParser) },
624 { "EArmObjCpcInfo", CmArmCpcInfoParser,
625 ARRAY_SIZE (CmArmCpcInfoParser) },
626 { "EArmObjMax", NULL, 0 },
627 };
628
629 /** A parser for EStdObjCfgMgrInfo.
630 */
631 STATIC CONST CM_OBJ_PARSER StdObjCfgMgrInfoParser[] = {
632 { "Revision", 4, "0x%x", NULL },
633 { "OemId[6]", 6, "%C%C%C%C%C%C", PrintOemId }
634 };
635
636 /** A parser for EStdObjAcpiTableList.
637 */
638 STATIC CONST CM_OBJ_PARSER StdObjAcpiTableInfoParser[] = {
639 { "AcpiTableSignature", 4, "0x%x", NULL },
640 { "AcpiTableRevision", 1, "%d", NULL },
641 { "TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", NULL },
642 { "AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER *), "0x%p", NULL },
643 { "OemTableId", 8, "0x%LLX", NULL },
644 { "OemRevision", 4, "0x%x", NULL },
645 { "MinorRevision", 1, "0x%x", NULL },
646 };
647
648 /** A parser for EStdObjSmbiosTableList.
649 */
650 STATIC CONST CM_OBJ_PARSER StdObjSmbiosTableInfoParser[] = {
651 { "TableGeneratorId", sizeof (SMBIOS_TABLE_GENERATOR_ID), "0x%x", NULL },
652 { "SmbiosTableData", sizeof (SMBIOS_STRUCTURE *), "0x%p", NULL }
653 };
654
655 /** A parser for Standard namespace objects.
656 */
657 STATIC CONST CM_OBJ_PARSER_ARRAY StdNamespaceObjectParser[] = {
658 { "EStdObjCfgMgrInfo", StdObjCfgMgrInfoParser,
659 ARRAY_SIZE (StdObjCfgMgrInfoParser) },
660 { "EStdObjAcpiTableList", StdObjAcpiTableInfoParser,
661 ARRAY_SIZE (StdObjAcpiTableInfoParser) },
662 { "EStdObjSmbiosTableList", StdObjSmbiosTableInfoParser,
663 ARRAY_SIZE (StdObjSmbiosTableInfoParser) },
664 };
665
666 /** Print OEM Id.
667
668 @param [in] Format Format to print the Ptr.
669 @param [in] Ptr Pointer to the OEM Id.
670 **/
671 STATIC
672 VOID
673 EFIAPI
674 PrintOemId (
675 IN CONST CHAR8 *Format,
676 IN UINT8 *Ptr
677 )
678 {
679 DEBUG ((
680 DEBUG_ERROR,
681 (Format != NULL) ? Format : "%C%C%C%C%C%C",
682 Ptr[0],
683 Ptr[1],
684 Ptr[2],
685 Ptr[3],
686 Ptr[4],
687 Ptr[5]
688 ));
689 }
690
691 /** Print string.
692
693 The string must be NULL terminated.
694
695 @param [in] Format Format to print the Ptr.
696 @param [in] Ptr Pointer to the string.
697 **/
698 STATIC
699 VOID
700 EFIAPI
701 PrintString (
702 CONST CHAR8 *Format,
703 UINT8 *Ptr
704 )
705 {
706 DEBUG ((DEBUG_ERROR, "%a", Ptr));
707 }
708
709 /** Print fields of the objects.
710
711 @param [in] Data Pointer to the object to print.
712 @param [in] Parser Parser containing the object fields.
713 @param [in] ItemCount Number of entries/fields in the Parser.
714 @param [in] RemainingSize Parse at most *RemainingSize bytes.
715 This function decrements the value
716 from the number bytes consumed.
717 @param [in] IndentLevel Indentation to use when printing.
718 **/
719 STATIC
720 VOID
721 PrintCmObjDesc (
722 IN VOID *Data,
723 IN CONST CM_OBJ_PARSER *Parser,
724 IN UINTN ItemCount,
725 IN INTN *RemainingSize,
726 IN UINT32 IndentLevel
727 )
728 {
729 UINT32 Index;
730 UINT32 IndentIndex;
731 INTN SubStructSize;
732
733 if ((Data == NULL) ||
734 (Parser == NULL) ||
735 (ItemCount == 0) ||
736 (RemainingSize == NULL))
737 {
738 ASSERT (0);
739 return;
740 }
741
742 // Print each field.
743 for (Index = 0; Index < ItemCount; Index++) {
744 // Check there is enough space in left.
745 *RemainingSize -= Parser[Index].Length;
746 if (*RemainingSize < 0) {
747 DEBUG ((
748 DEBUG_ERROR,
749 "\nERROR: %a: Buffer overrun\n",
750 Parser[Index].NameStr
751 ));
752 ASSERT (0);
753 return;
754 }
755
756 // Indentation
757 for (IndentIndex = 0; IndentIndex < IndentLevel; IndentIndex++) {
758 DEBUG ((DEBUG_ERROR, " "));
759 }
760
761 DEBUG ((
762 DEBUG_ERROR,
763 "%-*a :",
764 OUTPUT_FIELD_COLUMN_WIDTH - 2 * IndentLevel,
765 Parser[Index].NameStr
766 ));
767 if (Parser[Index].PrintFormatter != NULL) {
768 Parser[Index].PrintFormatter (Parser[Index].Format, Data);
769 } else if (Parser[Index].Format != NULL) {
770 switch (Parser[Index].Length) {
771 case 1:
772 DEBUG ((DEBUG_ERROR, Parser[Index].Format, *(UINT8 *)Data));
773 break;
774 case 2:
775 DEBUG ((DEBUG_ERROR, Parser[Index].Format, *(UINT16 *)Data));
776 break;
777 case 4:
778 DEBUG ((DEBUG_ERROR, Parser[Index].Format, *(UINT32 *)Data));
779 break;
780 case 8:
781 DEBUG ((DEBUG_ERROR, Parser[Index].Format, ReadUnaligned64 (Data)));
782 break;
783 default:
784 DEBUG ((
785 DEBUG_ERROR,
786 "\nERROR: %a: CANNOT PARSE THIS FIELD, Field Length = %d\n",
787 Parser[Index].NameStr,
788 Parser[Index].Length
789 ));
790 } // switch
791 } else if (Parser[Index].SubObjParser != NULL) {
792 SubStructSize = Parser[Index].Length;
793
794 DEBUG ((DEBUG_ERROR, "\n"));
795 PrintCmObjDesc (
796 Data,
797 Parser[Index].SubObjParser,
798 Parser[Index].SubObjItemCount,
799 &SubStructSize,
800 IndentLevel + 1
801 );
802 } else {
803 ASSERT (0);
804 DEBUG ((
805 DEBUG_ERROR,
806 "\nERROR: %a: CANNOT PARSE THIS FIELD, Field Length = %d\n",
807 Parser[Index].NameStr,
808 Parser[Index].Length
809 ));
810 }
811
812 DEBUG ((DEBUG_ERROR, "\n"));
813 Data = (UINT8 *)Data + Parser[Index].Length;
814 } // for
815 }
816
817 /** Parse and print a CmObjDesc.
818
819 @param [in] CmObjDesc The CmObjDesc to parse and print.
820 **/
821 VOID
822 EFIAPI
823 ParseCmObjDesc (
824 IN CONST CM_OBJ_DESCRIPTOR *CmObjDesc
825 )
826 {
827 UINTN ObjId;
828 UINTN NameSpaceId;
829 UINT32 ObjIndex;
830 UINT32 ObjectCount;
831 INTN RemainingSize;
832 INTN Offset;
833 CONST CM_OBJ_PARSER_ARRAY *ParserArray;
834
835 if ((CmObjDesc == NULL) || (CmObjDesc->Data == NULL)) {
836 return;
837 }
838
839 NameSpaceId = GET_CM_NAMESPACE_ID (CmObjDesc->ObjectId);
840 ObjId = GET_CM_OBJECT_ID (CmObjDesc->ObjectId);
841
842 switch (NameSpaceId) {
843 case EObjNameSpaceStandard:
844 if (ObjId >= EStdObjMax) {
845 ASSERT (0);
846 return;
847 }
848
849 ParserArray = &StdNamespaceObjectParser[ObjId];
850 break;
851 case EObjNameSpaceArm:
852 if (ObjId >= EArmObjMax) {
853 ASSERT (0);
854 return;
855 }
856
857 ParserArray = &ArmNamespaceObjectParser[ObjId];
858 break;
859 default:
860 // Not supported
861 ASSERT (0);
862 return;
863 } // switch
864
865 ObjectCount = CmObjDesc->Count;
866 RemainingSize = CmObjDesc->Size;
867 Offset = 0;
868
869 for (ObjIndex = 0; ObjIndex < ObjectCount; ObjIndex++) {
870 DEBUG ((
871 DEBUG_ERROR,
872 "\n%-*a [%d/%d]:\n",
873 OUTPUT_FIELD_COLUMN_WIDTH,
874 ParserArray->ObjectName,
875 ObjIndex + 1,
876 ObjectCount
877 ));
878 PrintCmObjDesc (
879 (VOID *)((UINTN)CmObjDesc->Data + Offset),
880 ParserArray->Parser,
881 ParserArray->ItemCount,
882 &RemainingSize,
883 1
884 );
885 if ((RemainingSize > CmObjDesc->Size) ||
886 (RemainingSize < 0))
887 {
888 ASSERT (0);
889 return;
890 }
891
892 Offset = CmObjDesc->Size - RemainingSize;
893 } // for
894
895 ASSERT (RemainingSize == 0);
896 }