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