rsdump.c revision 1.5 1 /*******************************************************************************
2 *
3 * Module Name: rsdump - Functions to display the resource structures.
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #define __RSDUMP_C__
45
46 #include "acpi.h"
47 #include "accommon.h"
48 #include "acresrc.h"
49
50 #define _COMPONENT ACPI_RESOURCES
51 ACPI_MODULE_NAME ("rsdump")
52
53
54 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER)
55
56 /* Local prototypes */
57
58 static void
59 AcpiRsOutString (
60 const char *Title,
61 const char *Value);
62
63 static void
64 AcpiRsOutInteger8 (
65 const char *Title,
66 UINT8 Value);
67
68 static void
69 AcpiRsOutInteger16 (
70 const char *Title,
71 UINT16 Value);
72
73 static void
74 AcpiRsOutInteger32 (
75 const char *Title,
76 UINT32 Value);
77
78 static void
79 AcpiRsOutInteger64 (
80 const char *Title,
81 UINT64 Value);
82
83 static void
84 AcpiRsOutTitle (
85 const char *Title);
86
87 static void
88 AcpiRsDumpByteList (
89 UINT16 Length,
90 UINT8 *Data);
91
92 static void
93 AcpiRsDumpWordList (
94 UINT16 Length,
95 UINT16 *Data);
96
97 static void
98 AcpiRsDumpDwordList (
99 UINT8 Length,
100 UINT32 *Data);
101
102 static void
103 AcpiRsDumpShortByteList (
104 UINT8 Length,
105 UINT8 *Data);
106
107 static void
108 AcpiRsDumpResourceSource (
109 ACPI_RESOURCE_SOURCE *ResourceSource);
110
111 static void
112 AcpiRsDumpAddressCommon (
113 ACPI_RESOURCE_DATA *Resource);
114
115 static void
116 AcpiRsDumpDescriptor (
117 void *Resource,
118 ACPI_RSDUMP_INFO *Table);
119
120
121 /*******************************************************************************
122 *
123 * FUNCTION: AcpiRsDumpDescriptor
124 *
125 * PARAMETERS: Resource - Buffer containing the resource
126 * Table - Table entry to decode the resource
127 *
128 * RETURN: None
129 *
130 * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
131 *
132 ******************************************************************************/
133
134 static void
135 AcpiRsDumpDescriptor (
136 void *Resource,
137 ACPI_RSDUMP_INFO *Table)
138 {
139 UINT8 *Target = NULL;
140 UINT8 *PreviousTarget;
141 const char *Name;
142 UINT8 Count;
143
144
145 /* First table entry must contain the table length (# of table entries) */
146
147 Count = Table->Offset;
148
149 while (Count)
150 {
151 PreviousTarget = Target;
152 Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset);
153 Name = Table->Name;
154
155 switch (Table->Opcode)
156 {
157 case ACPI_RSD_TITLE:
158 /*
159 * Optional resource title
160 */
161 if (Table->Name)
162 {
163 AcpiOsPrintf ("%s Resource\n", Name);
164 }
165 break;
166
167 /* Strings */
168
169 case ACPI_RSD_LITERAL:
170
171 AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer));
172 break;
173
174 case ACPI_RSD_STRING:
175
176 AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target));
177 break;
178
179 /* Data items, 8/16/32/64 bit */
180
181 case ACPI_RSD_UINT8:
182
183 if (Table->Pointer)
184 {
185 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
186 Table->Pointer [*Target]));
187 }
188 else
189 {
190 AcpiRsOutInteger8 (Name, ACPI_GET8 (Target));
191 }
192 break;
193
194 case ACPI_RSD_UINT16:
195
196 AcpiRsOutInteger16 (Name, ACPI_GET16 (Target));
197 break;
198
199 case ACPI_RSD_UINT32:
200
201 AcpiRsOutInteger32 (Name, ACPI_GET32 (Target));
202 break;
203
204 case ACPI_RSD_UINT64:
205
206 AcpiRsOutInteger64 (Name, ACPI_GET64 (Target));
207 break;
208
209 /* Flags: 1-bit and 2-bit flags supported */
210
211 case ACPI_RSD_1BITFLAG:
212
213 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
214 Table->Pointer [*Target & 0x01]));
215 break;
216
217 case ACPI_RSD_2BITFLAG:
218
219 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
220 Table->Pointer [*Target & 0x03]));
221 break;
222
223 case ACPI_RSD_3BITFLAG:
224
225 AcpiRsOutString (Name, ACPI_CAST_PTR (char,
226 Table->Pointer [*Target & 0x07]));
227 break;
228
229 case ACPI_RSD_SHORTLIST:
230 /*
231 * Short byte list (single line output) for DMA and IRQ resources
232 * Note: The list length is obtained from the previous table entry
233 */
234 if (PreviousTarget)
235 {
236 AcpiRsOutTitle (Name);
237 AcpiRsDumpShortByteList (*PreviousTarget, Target);
238 }
239 break;
240
241 case ACPI_RSD_SHORTLISTX:
242 /*
243 * Short byte list (single line output) for GPIO vendor data
244 * Note: The list length is obtained from the previous table entry
245 */
246 if (PreviousTarget)
247 {
248 AcpiRsOutTitle (Name);
249 AcpiRsDumpShortByteList (*PreviousTarget,
250 *(ACPI_CAST_INDIRECT_PTR (UINT8, Target)));
251 }
252 break;
253
254 case ACPI_RSD_LONGLIST:
255 /*
256 * Long byte list for Vendor resource data
257 * Note: The list length is obtained from the previous table entry
258 */
259 if (PreviousTarget)
260 {
261 AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target);
262 }
263 break;
264
265 case ACPI_RSD_DWORDLIST:
266 /*
267 * Dword list for Extended Interrupt resources
268 * Note: The list length is obtained from the previous table entry
269 */
270 if (PreviousTarget)
271 {
272 AcpiRsDumpDwordList (*PreviousTarget,
273 ACPI_CAST_PTR (UINT32, Target));
274 }
275 break;
276
277 case ACPI_RSD_WORDLIST:
278 /*
279 * Word list for GPIO Pin Table
280 * Note: The list length is obtained from the previous table entry
281 */
282 if (PreviousTarget)
283 {
284 AcpiRsDumpWordList (*PreviousTarget,
285 *(ACPI_CAST_INDIRECT_PTR (UINT16, Target)));
286 }
287 break;
288
289 case ACPI_RSD_ADDRESS:
290 /*
291 * Common flags for all Address resources
292 */
293 AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target));
294 break;
295
296 case ACPI_RSD_SOURCE:
297 /*
298 * Optional ResourceSource for Address resources
299 */
300 AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target));
301 break;
302
303 default:
304
305 AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
306 Table->Opcode);
307 return;
308 }
309
310 Table++;
311 Count--;
312 }
313 }
314
315
316 /*******************************************************************************
317 *
318 * FUNCTION: AcpiRsDumpResourceSource
319 *
320 * PARAMETERS: ResourceSource - Pointer to a Resource Source struct
321 *
322 * RETURN: None
323 *
324 * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
325 * corresponding ResourceSourceIndex.
326 *
327 ******************************************************************************/
328
329 static void
330 AcpiRsDumpResourceSource (
331 ACPI_RESOURCE_SOURCE *ResourceSource)
332 {
333 ACPI_FUNCTION_ENTRY ();
334
335
336 if (ResourceSource->Index == 0xFF)
337 {
338 return;
339 }
340
341 AcpiRsOutInteger8 ("Resource Source Index",
342 ResourceSource->Index);
343
344 AcpiRsOutString ("Resource Source",
345 ResourceSource->StringPtr ?
346 ResourceSource->StringPtr : "[Not Specified]");
347 }
348
349
350 /*******************************************************************************
351 *
352 * FUNCTION: AcpiRsDumpAddressCommon
353 *
354 * PARAMETERS: Resource - Pointer to an internal resource descriptor
355 *
356 * RETURN: None
357 *
358 * DESCRIPTION: Dump the fields that are common to all Address resource
359 * descriptors
360 *
361 ******************************************************************************/
362
363 static void
364 AcpiRsDumpAddressCommon (
365 ACPI_RESOURCE_DATA *Resource)
366 {
367 ACPI_FUNCTION_ENTRY ();
368
369
370 /* Decode the type-specific flags */
371
372 switch (Resource->Address.ResourceType)
373 {
374 case ACPI_MEMORY_RANGE:
375
376 AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
377 break;
378
379 case ACPI_IO_RANGE:
380
381 AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
382 break;
383
384 case ACPI_BUS_NUMBER_RANGE:
385
386 AcpiRsOutString ("Resource Type", "Bus Number Range");
387 break;
388
389 default:
390
391 AcpiRsOutInteger8 ("Resource Type",
392 (UINT8) Resource->Address.ResourceType);
393 break;
394 }
395
396 /* Decode the general flags */
397
398 AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
399 }
400
401
402 /*******************************************************************************
403 *
404 * FUNCTION: AcpiRsDumpResourceList
405 *
406 * PARAMETERS: ResourceList - Pointer to a resource descriptor list
407 *
408 * RETURN: None
409 *
410 * DESCRIPTION: Dispatches the structure to the correct dump routine.
411 *
412 ******************************************************************************/
413
414 void
415 AcpiRsDumpResourceList (
416 ACPI_RESOURCE *ResourceList)
417 {
418 UINT32 Count = 0;
419 UINT32 Type;
420
421
422 ACPI_FUNCTION_ENTRY ();
423
424
425 /* Check if debug output enabled */
426
427 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES, _COMPONENT))
428 {
429 return;
430 }
431
432 /* Walk list and dump all resource descriptors (END_TAG terminates) */
433
434 do
435 {
436 AcpiOsPrintf ("\n[%02X] ", Count);
437 Count++;
438
439 /* Validate Type before dispatch */
440
441 Type = ResourceList->Type;
442 if (Type > ACPI_RESOURCE_TYPE_MAX)
443 {
444 AcpiOsPrintf (
445 "Invalid descriptor type (%X) in resource list\n",
446 ResourceList->Type);
447 return;
448 }
449
450 /* Sanity check the length. It must not be zero, or we loop forever */
451
452 if (!ResourceList->Length)
453 {
454 AcpiOsPrintf (
455 "Invalid zero length descriptor in resource list\n");
456 return;
457 }
458
459 /* Dump the resource descriptor */
460
461 if (Type == ACPI_RESOURCE_TYPE_SERIAL_BUS)
462 {
463 AcpiRsDumpDescriptor (&ResourceList->Data,
464 AcpiGbl_DumpSerialBusDispatch[ResourceList->Data.CommonSerialBus.Type]);
465 }
466 else
467 {
468 AcpiRsDumpDescriptor (&ResourceList->Data,
469 AcpiGbl_DumpResourceDispatch[Type]);
470 }
471
472 /* Point to the next resource structure */
473
474 ResourceList = ACPI_NEXT_RESOURCE (ResourceList);
475
476 /* Exit when END_TAG descriptor is reached */
477
478 } while (Type != ACPI_RESOURCE_TYPE_END_TAG);
479 }
480
481
482 /*******************************************************************************
483 *
484 * FUNCTION: AcpiRsDumpIrqList
485 *
486 * PARAMETERS: RouteTable - Pointer to the routing table to dump.
487 *
488 * RETURN: None
489 *
490 * DESCRIPTION: Print IRQ routing table
491 *
492 ******************************************************************************/
493
494 void
495 AcpiRsDumpIrqList (
496 UINT8 *RouteTable)
497 {
498 ACPI_PCI_ROUTING_TABLE *PrtElement;
499 UINT8 Count;
500
501
502 ACPI_FUNCTION_ENTRY ();
503
504
505 /* Check if debug output enabled */
506
507 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_RESOURCES, _COMPONENT))
508 {
509 return;
510 }
511
512 PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
513
514 /* Dump all table elements, Exit on zero length element */
515
516 for (Count = 0; PrtElement->Length; Count++)
517 {
518 AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
519 AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
520
521 PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE,
522 PrtElement, PrtElement->Length);
523 }
524 }
525
526
527 /*******************************************************************************
528 *
529 * FUNCTION: AcpiRsOut*
530 *
531 * PARAMETERS: Title - Name of the resource field
532 * Value - Value of the resource field
533 *
534 * RETURN: None
535 *
536 * DESCRIPTION: Miscellaneous helper functions to consistently format the
537 * output of the resource dump routines
538 *
539 ******************************************************************************/
540
541 static void
542 AcpiRsOutString (
543 const char *Title,
544 const char *Value)
545 {
546 AcpiOsPrintf ("%27s : %s", Title, Value);
547 if (!*Value)
548 {
549 AcpiOsPrintf ("[NULL NAMESTRING]");
550 }
551 AcpiOsPrintf ("\n");
552 }
553
554 static void
555 AcpiRsOutInteger8 (
556 const char *Title,
557 UINT8 Value)
558 {
559 AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
560 }
561
562 static void
563 AcpiRsOutInteger16 (
564 const char *Title,
565 UINT16 Value)
566 {
567 AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
568 }
569
570 static void
571 AcpiRsOutInteger32 (
572 const char *Title,
573 UINT32 Value)
574 {
575 AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
576 }
577
578 static void
579 AcpiRsOutInteger64 (
580 const char *Title,
581 UINT64 Value)
582 {
583 AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
584 ACPI_FORMAT_UINT64 (Value));
585 }
586
587 static void
588 AcpiRsOutTitle (
589 const char *Title)
590 {
591 AcpiOsPrintf ("%27s : ", Title);
592 }
593
594
595 /*******************************************************************************
596 *
597 * FUNCTION: AcpiRsDump*List
598 *
599 * PARAMETERS: Length - Number of elements in the list
600 * Data - Start of the list
601 *
602 * RETURN: None
603 *
604 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
605 *
606 ******************************************************************************/
607
608 static void
609 AcpiRsDumpByteList (
610 UINT16 Length,
611 UINT8 *Data)
612 {
613 UINT8 i;
614
615
616 for (i = 0; i < Length; i++)
617 {
618 AcpiOsPrintf ("%25s%2.2X : %2.2X\n",
619 "Byte", i, Data[i]);
620 }
621 }
622
623 static void
624 AcpiRsDumpShortByteList (
625 UINT8 Length,
626 UINT8 *Data)
627 {
628 UINT8 i;
629
630
631 for (i = 0; i < Length; i++)
632 {
633 AcpiOsPrintf ("%X ", Data[i]);
634 }
635 AcpiOsPrintf ("\n");
636 }
637
638 static void
639 AcpiRsDumpDwordList (
640 UINT8 Length,
641 UINT32 *Data)
642 {
643 UINT8 i;
644
645
646 for (i = 0; i < Length; i++)
647 {
648 AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
649 "Dword", i, Data[i]);
650 }
651 }
652
653 static void
654 AcpiRsDumpWordList (
655 UINT16 Length,
656 UINT16 *Data)
657 {
658 UINT16 i;
659
660
661 for (i = 0; i < Length; i++)
662 {
663 AcpiOsPrintf ("%25s%2.2X : %4.4X\n",
664 "Word", i, Data[i]);
665 }
666 }
667
668 #endif
669