1 /*******************************************************************************
2  *
3  * Module Name: dmresrcl.c - "Large" Resource Descriptor disassembly
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2015, 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 #include <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/acdisasm.h>
47 
48 
49 #define _COMPONENT          ACPI_CA_DEBUGGER
50         ACPI_MODULE_NAME    ("dbresrcl")
51 
52 
53 /* Common names for address and memory descriptors */
54 
55 static char                 *AcpiDmAddressNames[] =
56 {
57     "Granularity",
58     "Range Minimum",
59     "Range Maximum",
60     "Translation Offset",
61     "Length"
62 };
63 
64 static char                 *AcpiDmMemoryNames[] =
65 {
66     "Range Minimum",
67     "Range Maximum",
68     "Alignment",
69     "Length"
70 };
71 
72 
73 /* Local prototypes */
74 
75 static void
76 AcpiDmSpaceFlags (
77         UINT8               Flags);
78 
79 static void
80 AcpiDmIoFlags (
81         UINT8               Flags);
82 
83 static void
84 AcpiDmIoFlags2 (
85         UINT8               SpecificFlags);
86 
87 static void
88 AcpiDmMemoryFlags (
89     UINT8                   Flags,
90     UINT8                   SpecificFlags);
91 
92 static void
93 AcpiDmMemoryFlags2 (
94     UINT8                   SpecificFlags);
95 
96 static void
97 AcpiDmResourceSource (
98     AML_RESOURCE            *Resource,
99     ACPI_SIZE               MinimumLength,
100     UINT32                  Length);
101 
102 static void
103 AcpiDmAddressFields (
104     void                    *Source,
105     UINT8                   Type,
106     UINT32                  Level);
107 
108 static void
109 AcpiDmAddressPrefix (
110     UINT8                   Type);
111 
112 static void
113 AcpiDmAddressCommon (
114     AML_RESOURCE            *Resource,
115     UINT8                   Type,
116     UINT32                  Level);
117 
118 static void
119 AcpiDmAddressFlags (
120     AML_RESOURCE            *Resource);
121 
122 
123 /*******************************************************************************
124  *
125  * FUNCTION:    AcpiDmMemoryFields
126  *
127  * PARAMETERS:  Source              - Pointer to the contiguous data fields
128  *              Type                - 16 or 32 (bit)
129  *              Level               - Current source code indentation level
130  *
131  * RETURN:      None
132  *
133  * DESCRIPTION: Decode fields common to Memory24 and Memory32 descriptors
134  *
135  ******************************************************************************/
136 
137 static void
138 AcpiDmMemoryFields (
139     void                    *Source,
140     UINT8                   Type,
141     UINT32                  Level)
142 {
143     UINT32                  i;
144 
145 
146     for (i = 0; i < 4; i++)
147     {
148         AcpiDmIndent (Level + 1);
149 
150         switch (Type)
151         {
152         case 16:
153 
154             AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
155                 AcpiDmMemoryNames[i]);
156             break;
157 
158         case 32:
159 
160             AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
161                 AcpiDmMemoryNames[i]);
162             break;
163 
164         default:
165 
166             return;
167         }
168     }
169 }
170 
171 
172 /*******************************************************************************
173  *
174  * FUNCTION:    AcpiDmAddressFields
175  *
176  * PARAMETERS:  Source              - Pointer to the contiguous data fields
177  *              Type                - 16, 32, or 64 (bit)
178  *              Level               - Current source code indentation level
179  *
180  * RETURN:      None
181  *
182  * DESCRIPTION: Decode fields common to address descriptors
183  *
184  ******************************************************************************/
185 
186 static void
187 AcpiDmAddressFields (
188     void                    *Source,
189     UINT8                   Type,
190     UINT32                  Level)
191 {
192     UINT32                  i;
193 
194 
195     AcpiOsPrintf ("\n");
196 
197     for (i = 0; i < 5; i++)
198     {
199         AcpiDmIndent (Level + 1);
200 
201         switch (Type)
202         {
203         case 16:
204 
205             AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
206                 AcpiDmAddressNames[i]);
207             break;
208 
209         case 32:
210 
211             AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
212                 AcpiDmAddressNames[i]);
213             break;
214 
215         case 64:
216 
217             AcpiDmDumpInteger64 (ACPI_CAST_PTR (UINT64, Source)[i],
218                 AcpiDmAddressNames[i]);
219             break;
220 
221         default:
222 
223             return;
224         }
225     }
226 }
227 
228 
229 /*******************************************************************************
230  *
231  * FUNCTION:    AcpiDmAddressPrefix
232  *
233  * PARAMETERS:  Type                - Descriptor type
234  *
235  * RETURN:      None
236  *
237  * DESCRIPTION: Emit name prefix representing the address descriptor type
238  *
239  ******************************************************************************/
240 
241 static void
242 AcpiDmAddressPrefix (
243     UINT8                   Type)
244 {
245 
246     switch (Type)
247     {
248     case ACPI_RESOURCE_TYPE_ADDRESS16:
249 
250         AcpiOsPrintf ("Word");
251         break;
252 
253     case ACPI_RESOURCE_TYPE_ADDRESS32:
254 
255         AcpiOsPrintf ("DWord");
256         break;
257 
258     case ACPI_RESOURCE_TYPE_ADDRESS64:
259 
260         AcpiOsPrintf ("QWord");
261         break;
262 
263     case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
264 
265         AcpiOsPrintf ("Extended");
266         break;
267 
268     default:
269 
270         return;
271     }
272 }
273 
274 
275 /*******************************************************************************
276  *
277  * FUNCTION:    AcpiDmAddressCommon
278  *
279  * PARAMETERS:  Resource            - Raw AML descriptor
280  *              Type                - Descriptor type
281  *              Level               - Current source code indentation level
282  *
283  * RETURN:      None
284  *
285  * DESCRIPTION: Emit common name and flag fields common to address descriptors
286  *
287  ******************************************************************************/
288 
289 static void
290 AcpiDmAddressCommon (
291     AML_RESOURCE            *Resource,
292     UINT8                   Type,
293     UINT32                  Level)
294 {
295     UINT8                   ResourceType;
296     UINT8                   SpecificFlags;
297     UINT8                   Flags;
298 
299 
300     ResourceType = Resource->Address.ResourceType;
301     SpecificFlags = Resource->Address.SpecificFlags;
302     Flags = Resource->Address.Flags;
303 
304     AcpiDmIndent (Level);
305 
306     /* Validate ResourceType */
307 
308     if ((ResourceType > 2) && (ResourceType < 0xC0))
309     {
310         AcpiOsPrintf ("/**** Invalid Resource Type: 0x%X ****/", ResourceType);
311         return;
312     }
313 
314     /* Prefix is either Word, DWord, QWord, or Extended */
315 
316     AcpiDmAddressPrefix (Type);
317 
318     /* Resource Types above 0xC0 are vendor-defined */
319 
320     if (ResourceType > 2)
321     {
322         AcpiOsPrintf ("Space (0x%2.2X, ", ResourceType);
323         AcpiDmSpaceFlags (Flags);
324         AcpiOsPrintf (" 0x%2.2X,", SpecificFlags);
325         return;
326     }
327 
328     /* This is either a Memory, IO, or BusNumber descriptor (0,1,2) */
329 
330     AcpiOsPrintf ("%s (", AcpiGbl_WordDecode [ACPI_GET_2BIT_FLAG (ResourceType)]);
331 
332     /* Decode the general and type-specific flags */
333 
334     if (ResourceType == ACPI_MEMORY_RANGE)
335     {
336         AcpiDmMemoryFlags (Flags, SpecificFlags);
337     }
338     else /* IO range or BusNumberRange */
339     {
340         AcpiDmIoFlags (Flags);
341         if (ResourceType == ACPI_IO_RANGE)
342         {
343             AcpiOsPrintf (" %s,", AcpiGbl_RngDecode [ACPI_GET_2BIT_FLAG (SpecificFlags)]);
344         }
345     }
346 }
347 
348 
349 /*******************************************************************************
350  *
351  * FUNCTION:    AcpiDmAddressFlags
352  *
353  * PARAMETERS:  Resource        - Raw AML descriptor
354  *
355  * RETURN:      None
356  *
357  * DESCRIPTION: Emit flags common to address descriptors
358  *
359  ******************************************************************************/
360 
361 static void
362 AcpiDmAddressFlags (
363     AML_RESOURCE            *Resource)
364 {
365 
366     if (Resource->Address.ResourceType == ACPI_IO_RANGE)
367     {
368         AcpiDmIoFlags2 (Resource->Address.SpecificFlags);
369     }
370     else if (Resource->Address.ResourceType == ACPI_MEMORY_RANGE)
371     {
372         AcpiDmMemoryFlags2 (Resource->Address.SpecificFlags);
373     }
374 }
375 
376 
377 /*******************************************************************************
378  *
379  * FUNCTION:    AcpiDmSpaceFlags
380  *
381  * PARAMETERS:  Flags               - Flag byte to be decoded
382  *
383  * RETURN:      None
384  *
385  * DESCRIPTION: Decode the flags specific to Space Address space descriptors
386  *
387  ******************************************************************************/
388 
389 static void
390 AcpiDmSpaceFlags (
391     UINT8                   Flags)
392 {
393 
394     AcpiOsPrintf ("%s, %s, %s, %s,",
395         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Flags)],
396         AcpiGbl_DecDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 1)],
397         AcpiGbl_MinDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 2)],
398         AcpiGbl_MaxDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 3)]);
399 }
400 
401 
402 /*******************************************************************************
403  *
404  * FUNCTION:    AcpiDmIoFlags
405  *
406  * PARAMETERS:  Flags               - Flag byte to be decoded
407  *
408  * RETURN:      None
409  *
410  * DESCRIPTION: Decode the flags specific to IO Address space descriptors
411  *
412  ******************************************************************************/
413 
414 static void
415 AcpiDmIoFlags (
416         UINT8               Flags)
417 {
418     AcpiOsPrintf ("%s, %s, %s, %s,",
419         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Flags)],
420         AcpiGbl_MinDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 2)],
421         AcpiGbl_MaxDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 3)],
422         AcpiGbl_DecDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 1)]);
423 }
424 
425 
426 /*******************************************************************************
427  *
428  * FUNCTION:    AcpiDmIoFlags2
429  *
430  * PARAMETERS:  SpecificFlags       - "Specific" flag byte to be decoded
431  *
432  * RETURN:      None
433  *
434  * DESCRIPTION: Decode the flags specific to IO Address space descriptors
435  *
436  ******************************************************************************/
437 
438 static void
439 AcpiDmIoFlags2 (
440         UINT8               SpecificFlags)
441 {
442 
443     AcpiOsPrintf (", %s",
444         AcpiGbl_TtpDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 4)]);
445 
446     /* TRS is only used if TTP is TypeTranslation */
447 
448     if (SpecificFlags & 0x10)
449     {
450         AcpiOsPrintf (", %s",
451             AcpiGbl_TrsDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]);
452     }
453 }
454 
455 
456 /*******************************************************************************
457  *
458  * FUNCTION:    AcpiDmMemoryFlags
459  *
460  * PARAMETERS:  Flags               - Flag byte to be decoded
461  *              SpecificFlags       - "Specific" flag byte to be decoded
462  *
463  * RETURN:      None
464  *
465  * DESCRIPTION: Decode flags specific to Memory Address Space descriptors
466  *
467  ******************************************************************************/
468 
469 static void
470 AcpiDmMemoryFlags (
471     UINT8                   Flags,
472     UINT8                   SpecificFlags)
473 {
474 
475     AcpiOsPrintf ("%s, %s, %s, %s, %s, %s,",
476         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Flags)],
477         AcpiGbl_DecDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 1)],
478         AcpiGbl_MinDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 2)],
479         AcpiGbl_MaxDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 3)],
480         AcpiGbl_MemDecode [ACPI_EXTRACT_2BIT_FLAG (SpecificFlags, 1)],
481         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (SpecificFlags)]);
482 }
483 
484 
485 /*******************************************************************************
486  *
487  * FUNCTION:    AcpiDmMemoryFlags2
488  *
489  * PARAMETERS:  SpecificFlags       - "Specific" flag byte to be decoded
490  *
491  * RETURN:      None
492  *
493  * DESCRIPTION: Decode flags specific to Memory Address Space descriptors
494  *
495  ******************************************************************************/
496 
497 static void
498 AcpiDmMemoryFlags2 (
499     UINT8                   SpecificFlags)
500 {
501 
502     AcpiOsPrintf (", %s, %s",
503         AcpiGbl_MtpDecode [ACPI_EXTRACT_2BIT_FLAG (SpecificFlags, 3)],
504         AcpiGbl_TtpDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]);
505 }
506 
507 
508 /*******************************************************************************
509  *
510  * FUNCTION:    AcpiDmResourceSource
511  *
512  * PARAMETERS:  Resource        - Raw AML descriptor
513  *              MinimumLength   - descriptor length without optional fields
514  *              ResourceLength
515  *
516  * RETURN:      None
517  *
518  * DESCRIPTION: Dump optional ResourceSource fields of an address descriptor
519  *
520  ******************************************************************************/
521 
522 static void
523 AcpiDmResourceSource (
524     AML_RESOURCE            *Resource,
525     ACPI_SIZE               MinimumTotalLength,
526     UINT32                  ResourceLength)
527 {
528     UINT8                   *AmlResourceSource;
529     UINT32                  TotalLength;
530 
531 
532     TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
533 
534     /* Check if the optional ResourceSource fields are present */
535 
536     if (TotalLength <= MinimumTotalLength)
537     {
538         /* The two optional fields are not used */
539 
540         AcpiOsPrintf (",, ");
541         return;
542     }
543 
544     /* Get a pointer to the ResourceSource */
545 
546     AmlResourceSource = ACPI_ADD_PTR (UINT8, Resource, MinimumTotalLength);
547 
548     /*
549      * Always emit the ResourceSourceIndex (Byte)
550      *
551      * NOTE: Some ASL compilers always create a 0 byte (in the AML) for the
552      * Index even if the String does not exist. Although this is in violation
553      * of the ACPI specification, it is very important to emit ASL code that
554      * can be compiled back to the identical AML. There may be fields and/or
555      * indexes into the resource template buffer that are compiled to absolute
556      * offsets, and these will be broken if the AML length is changed.
557      */
558     AcpiOsPrintf ("0x%2.2X,", (UINT32) AmlResourceSource[0]);
559 
560     /* Make sure that the ResourceSource string exists before dumping it */
561 
562     if (TotalLength > (MinimumTotalLength + 1))
563     {
564         AcpiOsPrintf (" ");
565         AcpiUtPrintString ((char *) &AmlResourceSource[1], ACPI_UINT16_MAX);
566     }
567 
568     AcpiOsPrintf (", ");
569 }
570 
571 
572 /*******************************************************************************
573  *
574  * FUNCTION:    AcpiDmWordDescriptor
575  *
576  * PARAMETERS:  Info                - Extra resource info
577  *              Resource            - Pointer to the resource descriptor
578  *              Length              - Length of the descriptor in bytes
579  *              Level               - Current source code indentation level
580  *
581  * RETURN:      None
582  *
583  * DESCRIPTION: Decode a Word Address Space descriptor
584  *
585  ******************************************************************************/
586 
587 void
588 AcpiDmWordDescriptor (
589     ACPI_OP_WALK_INFO       *Info,
590     AML_RESOURCE            *Resource,
591     UINT32                  Length,
592     UINT32                  Level)
593 {
594 
595     /* Dump resource name and flags */
596 
597     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS16, Level);
598 
599     /* Dump the 5 contiguous WORD values */
600 
601     AcpiDmAddressFields (&Resource->Address16.Granularity, 16, Level);
602 
603     /* The ResourceSource fields are optional */
604 
605     AcpiDmIndent (Level + 1);
606     AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS16), Length);
607 
608     /* Insert a descriptor name */
609 
610     AcpiDmDescriptorName ();
611 
612     /* Type-specific flags */
613 
614     AcpiDmAddressFlags (Resource);
615     AcpiOsPrintf (")\n");
616 }
617 
618 
619 /*******************************************************************************
620  *
621  * FUNCTION:    AcpiDmDwordDescriptor
622  *
623  * PARAMETERS:  Info                - Extra resource info
624  *              Resource            - Pointer to the resource descriptor
625  *              Length              - Length of the descriptor in bytes
626  *              Level               - Current source code indentation level
627  *
628  * RETURN:      None
629  *
630  * DESCRIPTION: Decode a DWord Address Space descriptor
631  *
632  ******************************************************************************/
633 
634 void
635 AcpiDmDwordDescriptor (
636     ACPI_OP_WALK_INFO       *Info,
637     AML_RESOURCE            *Resource,
638     UINT32                  Length,
639     UINT32                  Level)
640 {
641 
642     /* Dump resource name and flags */
643 
644     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS32, Level);
645 
646     /* Dump the 5 contiguous DWORD values */
647 
648     AcpiDmAddressFields (&Resource->Address32.Granularity, 32, Level);
649 
650     /* The ResourceSource fields are optional */
651 
652     AcpiDmIndent (Level + 1);
653     AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS32), Length);
654 
655     /* Insert a descriptor name */
656 
657     AcpiDmDescriptorName ();
658 
659     /* Type-specific flags */
660 
661     AcpiDmAddressFlags (Resource);
662     AcpiOsPrintf (")\n");
663 }
664 
665 
666 /*******************************************************************************
667  *
668  * FUNCTION:    AcpiDmQwordDescriptor
669  *
670  * PARAMETERS:  Info                - Extra resource info
671  *              Resource            - Pointer to the resource descriptor
672  *              Length              - Length of the descriptor in bytes
673  *              Level               - Current source code indentation level
674  *
675  * RETURN:      None
676  *
677  * DESCRIPTION: Decode a QWord Address Space descriptor
678  *
679  ******************************************************************************/
680 
681 void
682 AcpiDmQwordDescriptor (
683     ACPI_OP_WALK_INFO       *Info,
684     AML_RESOURCE            *Resource,
685     UINT32                  Length,
686     UINT32                  Level)
687 {
688 
689     /* Dump resource name and flags */
690 
691     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS64, Level);
692 
693     /* Dump the 5 contiguous QWORD values */
694 
695     AcpiDmAddressFields (&Resource->Address64.Granularity, 64, Level);
696 
697     /* The ResourceSource fields are optional */
698 
699     AcpiDmIndent (Level + 1);
700     AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS64), Length);
701 
702     /* Insert a descriptor name */
703 
704     AcpiDmDescriptorName ();
705 
706     /* Type-specific flags */
707 
708     AcpiDmAddressFlags (Resource);
709     AcpiOsPrintf (")\n");
710 }
711 
712 
713 /*******************************************************************************
714  *
715  * FUNCTION:    AcpiDmExtendedDescriptor
716  *
717  * PARAMETERS:  Info                - Extra resource info
718  *              Resource            - Pointer to the resource descriptor
719  *              Length              - Length of the descriptor in bytes
720  *              Level               - Current source code indentation level
721  *
722  * RETURN:      None
723  *
724  * DESCRIPTION: Decode a Extended Address Space descriptor
725  *
726  ******************************************************************************/
727 
728 void
729 AcpiDmExtendedDescriptor (
730     ACPI_OP_WALK_INFO       *Info,
731     AML_RESOURCE            *Resource,
732     UINT32                  Length,
733     UINT32                  Level)
734 {
735 
736     /* Dump resource name and flags */
737 
738     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, Level);
739 
740     /* Dump the 5 contiguous QWORD values */
741 
742     AcpiDmAddressFields (&Resource->ExtAddress64.Granularity, 64, Level);
743 
744     /* Extra field for this descriptor only */
745 
746     AcpiDmIndent (Level + 1);
747     AcpiDmDumpInteger64 (Resource->ExtAddress64.TypeSpecific,
748         "Type-Specific Attributes");
749 
750     /* Insert a descriptor name */
751 
752     AcpiDmIndent (Level + 1);
753     AcpiDmDescriptorName ();
754 
755     /* Type-specific flags */
756 
757     AcpiDmAddressFlags (Resource);
758     AcpiOsPrintf (")\n");
759 }
760 
761 
762 /*******************************************************************************
763  *
764  * FUNCTION:    AcpiDmMemory24Descriptor
765  *
766  * PARAMETERS:  Info                - Extra resource info
767  *              Resource            - Pointer to the resource descriptor
768  *              Length              - Length of the descriptor in bytes
769  *              Level               - Current source code indentation level
770  *
771  * RETURN:      None
772  *
773  * DESCRIPTION: Decode a Memory24 descriptor
774  *
775  ******************************************************************************/
776 
777 void
778 AcpiDmMemory24Descriptor (
779     ACPI_OP_WALK_INFO       *Info,
780     AML_RESOURCE            *Resource,
781     UINT32                  Length,
782     UINT32                  Level)
783 {
784 
785     /* Dump name and read/write flag */
786 
787     AcpiDmIndent (Level);
788     AcpiOsPrintf ("Memory24 (%s,\n",
789         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->Memory24.Flags)]);
790 
791     /* Dump the 4 contiguous WORD values */
792 
793     AcpiDmMemoryFields (&Resource->Memory24.Minimum, 16, Level);
794 
795     /* Insert a descriptor name */
796 
797     AcpiDmIndent (Level + 1);
798     AcpiDmDescriptorName ();
799     AcpiOsPrintf (")\n");
800 }
801 
802 
803 /*******************************************************************************
804  *
805  * FUNCTION:    AcpiDmMemory32Descriptor
806  *
807  * PARAMETERS:  Info                - Extra resource info
808  *              Resource            - Pointer to the resource descriptor
809  *              Length              - Length of the descriptor in bytes
810  *              Level               - Current source code indentation level
811  *
812  * RETURN:      None
813  *
814  * DESCRIPTION: Decode a Memory32 descriptor
815  *
816  ******************************************************************************/
817 
818 void
819 AcpiDmMemory32Descriptor (
820     ACPI_OP_WALK_INFO       *Info,
821     AML_RESOURCE            *Resource,
822     UINT32                  Length,
823     UINT32                  Level)
824 {
825 
826     /* Dump name and read/write flag */
827 
828     AcpiDmIndent (Level);
829     AcpiOsPrintf ("Memory32 (%s,\n",
830         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->Memory32.Flags)]);
831 
832     /* Dump the 4 contiguous DWORD values */
833 
834     AcpiDmMemoryFields (&Resource->Memory32.Minimum, 32, Level);
835 
836     /* Insert a descriptor name */
837 
838     AcpiDmIndent (Level + 1);
839     AcpiDmDescriptorName ();
840     AcpiOsPrintf (")\n");
841 }
842 
843 
844 /*******************************************************************************
845  *
846  * FUNCTION:    AcpiDmFixedMemory32Descriptor
847  *
848  * PARAMETERS:  Info                - Extra resource info
849  *              Resource            - Pointer to the resource descriptor
850  *              Length              - Length of the descriptor in bytes
851  *              Level               - Current source code indentation level
852  *
853  * RETURN:      None
854  *
855  * DESCRIPTION: Decode a Fixed Memory32 descriptor
856  *
857  ******************************************************************************/
858 
859 void
860 AcpiDmFixedMemory32Descriptor (
861     ACPI_OP_WALK_INFO       *Info,
862     AML_RESOURCE            *Resource,
863     UINT32                  Length,
864     UINT32                  Level)
865 {
866 
867     /* Dump name and read/write flag */
868 
869     AcpiDmIndent (Level);
870     AcpiOsPrintf ("Memory32Fixed (%s,\n",
871         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->FixedMemory32.Flags)]);
872 
873     AcpiDmIndent (Level + 1);
874     AcpiDmDumpInteger32 (Resource->FixedMemory32.Address, "Address Base");
875 
876     AcpiDmIndent (Level + 1);
877     AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength, "Address Length");
878 
879     /* Insert a descriptor name */
880 
881     AcpiDmIndent (Level + 1);
882     AcpiDmDescriptorName ();
883     AcpiOsPrintf (")\n");
884 }
885 
886 
887 /*******************************************************************************
888  *
889  * FUNCTION:    AcpiDmGenericRegisterDescriptor
890  *
891  * PARAMETERS:  Info                - Extra resource info
892  *              Resource            - Pointer to the resource descriptor
893  *              Length              - Length of the descriptor in bytes
894  *              Level               - Current source code indentation level
895  *
896  * RETURN:      None
897  *
898  * DESCRIPTION: Decode a Generic Register descriptor
899  *
900  ******************************************************************************/
901 
902 void
903 AcpiDmGenericRegisterDescriptor (
904     ACPI_OP_WALK_INFO       *Info,
905     AML_RESOURCE            *Resource,
906     UINT32                  Length,
907     UINT32                  Level)
908 {
909 
910     AcpiDmIndent (Level);
911     AcpiOsPrintf ("Register (");
912     AcpiDmAddressSpace (Resource->GenericReg.AddressSpaceId);
913     AcpiOsPrintf ("\n");
914 
915     AcpiDmIndent (Level + 1);
916     AcpiDmDumpInteger8 (Resource->GenericReg.BitWidth, "Bit Width");
917 
918     AcpiDmIndent (Level + 1);
919     AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Bit Offset");
920 
921     AcpiDmIndent (Level + 1);
922     AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address");
923 
924     /* Optional field for ACPI 3.0 */
925 
926     AcpiDmIndent (Level + 1);
927     if (Resource->GenericReg.AccessSize)
928     {
929         AcpiOsPrintf ("0x%2.2X,               // %s\n",
930             Resource->GenericReg.AccessSize, "Access Size");
931         AcpiDmIndent (Level + 1);
932     }
933     else
934     {
935         AcpiOsPrintf (",");
936     }
937 
938     /* DescriptorName was added for ACPI 3.0+ */
939 
940     AcpiDmDescriptorName ();
941     AcpiOsPrintf (")\n");
942 }
943 
944 
945 /*******************************************************************************
946  *
947  * FUNCTION:    AcpiDmInterruptDescriptor
948  *
949  * PARAMETERS:  Info                - Extra resource info
950  *              Resource            - Pointer to the resource descriptor
951  *              Length              - Length of the descriptor in bytes
952  *              Level               - Current source code indentation level
953  *
954  * RETURN:      None
955  *
956  * DESCRIPTION: Decode a extended Interrupt descriptor
957  *
958  ******************************************************************************/
959 
960 void
961 AcpiDmInterruptDescriptor (
962     ACPI_OP_WALK_INFO       *Info,
963     AML_RESOURCE            *Resource,
964     UINT32                  Length,
965     UINT32                  Level)
966 {
967     UINT32                  i;
968 
969 
970     AcpiDmIndent (Level);
971     AcpiOsPrintf ("Interrupt (%s, %s, %s, %s, ",
972         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->ExtendedIrq.Flags)],
973         AcpiGbl_HeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->ExtendedIrq.Flags, 1)],
974         AcpiGbl_LlDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->ExtendedIrq.Flags, 2)],
975         AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->ExtendedIrq.Flags, 3)]);
976 
977     /*
978      * The ResourceSource fields are optional and appear after the interrupt
979      * list. Must compute length based on length of the list. First xrupt
980      * is included in the struct (reason for -1 below)
981      */
982     AcpiDmResourceSource (Resource,
983         sizeof (AML_RESOURCE_EXTENDED_IRQ) +
984             ((UINT32) Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32),
985         Resource->ExtendedIrq.ResourceLength);
986 
987     /* Insert a descriptor name */
988 
989     AcpiDmDescriptorName ();
990     AcpiOsPrintf (")\n");
991 
992     /* Dump the interrupt list */
993 
994     AcpiDmIndent (Level);
995     AcpiOsPrintf ("{\n");
996     for (i = 0; i < Resource->ExtendedIrq.InterruptCount; i++)
997     {
998         AcpiDmIndent (Level + 1);
999         AcpiOsPrintf ("0x%8.8X,\n",
1000             (UINT32) Resource->ExtendedIrq.Interrupts[i]);
1001     }
1002 
1003     AcpiDmIndent (Level);
1004     AcpiOsPrintf ("}\n");
1005 }
1006 
1007 
1008 /*******************************************************************************
1009  *
1010  * FUNCTION:    AcpiDmVendorCommon
1011  *
1012  * PARAMETERS:  Name                - Descriptor name suffix
1013  *              ByteData            - Pointer to the vendor byte data
1014  *              Length              - Length of the byte data
1015  *              Level               - Current source code indentation level
1016  *
1017  * RETURN:      None
1018  *
1019  * DESCRIPTION: Decode a Vendor descriptor, both Large and Small
1020  *
1021  ******************************************************************************/
1022 
1023 void
1024 AcpiDmVendorCommon (
1025     char                    *Name,
1026     UINT8                   *ByteData,
1027     UINT32                  Length,
1028     UINT32                  Level)
1029 {
1030 
1031     /* Dump macro name */
1032 
1033     AcpiDmIndent (Level);
1034     AcpiOsPrintf ("Vendor%s (", Name);
1035 
1036     /* Insert a descriptor name */
1037 
1038     AcpiDmDescriptorName ();
1039     AcpiOsPrintf (")      // Length = 0x%.2X\n", Length);
1040 
1041     /* Dump the vendor bytes */
1042 
1043     AcpiDmIndent (Level);
1044     AcpiOsPrintf ("{\n");
1045 
1046     AcpiDmDisasmByteList (Level + 1, ByteData, Length);
1047 
1048     AcpiDmIndent (Level);
1049     AcpiOsPrintf ("}\n");
1050 }
1051 
1052 
1053 /*******************************************************************************
1054  *
1055  * FUNCTION:    AcpiDmVendorLargeDescriptor
1056  *
1057  * PARAMETERS:  Info                - Extra resource info
1058  *              Resource            - Pointer to the resource descriptor
1059  *              Length              - Length of the descriptor in bytes
1060  *              Level               - Current source code indentation level
1061  *
1062  * RETURN:      None
1063  *
1064  * DESCRIPTION: Decode a Vendor Large descriptor
1065  *
1066  ******************************************************************************/
1067 
1068 void
1069 AcpiDmVendorLargeDescriptor (
1070     ACPI_OP_WALK_INFO       *Info,
1071     AML_RESOURCE            *Resource,
1072     UINT32                  Length,
1073     UINT32                  Level)
1074 {
1075 
1076     AcpiDmVendorCommon ("Long ",
1077         ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_LARGE_HEADER)),
1078         Length, Level);
1079 }
1080