Merge remote-tracking branch 'origin/vendor/BINUTILS227'
[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 - 2016, 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 const char           *AcpiDmAddressNames[] =
58 {
59     "Granularity",
60     "Range Minimum",
61     "Range Maximum",
62     "Translation Offset",
63     "Length"
64 };
65
66 static const 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 (
313             "/**** Invalid Resource Type: 0x%X ****/", ResourceType);
314         return;
315     }
316
317     /* Prefix is either Word, DWord, QWord, or Extended */
318
319     AcpiDmAddressPrefix (Type);
320
321     /* Resource Types above 0xC0 are vendor-defined */
322
323     if (ResourceType > 2)
324     {
325         AcpiOsPrintf ("Space (0x%2.2X, ", ResourceType);
326         AcpiDmSpaceFlags (Flags);
327         AcpiOsPrintf (" 0x%2.2X,", SpecificFlags);
328         return;
329     }
330
331     /* This is either a Memory, IO, or BusNumber descriptor (0,1,2) */
332
333     AcpiOsPrintf ("%s (",
334         AcpiGbl_WordDecode [ACPI_GET_2BIT_FLAG (ResourceType)]);
335
336     /* Decode the general and type-specific flags */
337
338     if (ResourceType == ACPI_MEMORY_RANGE)
339     {
340         AcpiDmMemoryFlags (Flags, SpecificFlags);
341     }
342     else /* IO range or BusNumberRange */
343     {
344         AcpiDmIoFlags (Flags);
345         if (ResourceType == ACPI_IO_RANGE)
346         {
347             AcpiOsPrintf (" %s,",
348                 AcpiGbl_RngDecode [ACPI_GET_2BIT_FLAG (SpecificFlags)]);
349         }
350     }
351 }
352
353
354 /*******************************************************************************
355  *
356  * FUNCTION:    AcpiDmAddressFlags
357  *
358  * PARAMETERS:  Resource        - Raw AML descriptor
359  *
360  * RETURN:      None
361  *
362  * DESCRIPTION: Emit flags common to address descriptors
363  *
364  ******************************************************************************/
365
366 static void
367 AcpiDmAddressFlags (
368     AML_RESOURCE            *Resource)
369 {
370
371     if (Resource->Address.ResourceType == ACPI_IO_RANGE)
372     {
373         AcpiDmIoFlags2 (Resource->Address.SpecificFlags);
374     }
375     else if (Resource->Address.ResourceType == ACPI_MEMORY_RANGE)
376     {
377         AcpiDmMemoryFlags2 (Resource->Address.SpecificFlags);
378     }
379 }
380
381
382 /*******************************************************************************
383  *
384  * FUNCTION:    AcpiDmSpaceFlags
385  *
386  * PARAMETERS:  Flags               - Flag byte to be decoded
387  *
388  * RETURN:      None
389  *
390  * DESCRIPTION: Decode the flags specific to Space Address space descriptors
391  *
392  ******************************************************************************/
393
394 static void
395 AcpiDmSpaceFlags (
396     UINT8                   Flags)
397 {
398
399     AcpiOsPrintf ("%s, %s, %s, %s,",
400         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Flags)],
401         AcpiGbl_DecDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 1)],
402         AcpiGbl_MinDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 2)],
403         AcpiGbl_MaxDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 3)]);
404 }
405
406
407 /*******************************************************************************
408  *
409  * FUNCTION:    AcpiDmIoFlags
410  *
411  * PARAMETERS:  Flags               - Flag byte to be decoded
412  *
413  * RETURN:      None
414  *
415  * DESCRIPTION: Decode the flags specific to IO Address space descriptors
416  *
417  ******************************************************************************/
418
419 static void
420 AcpiDmIoFlags (
421         UINT8               Flags)
422 {
423     AcpiOsPrintf ("%s, %s, %s, %s,",
424         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Flags)],
425         AcpiGbl_MinDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 2)],
426         AcpiGbl_MaxDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 3)],
427         AcpiGbl_DecDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 1)]);
428 }
429
430
431 /*******************************************************************************
432  *
433  * FUNCTION:    AcpiDmIoFlags2
434  *
435  * PARAMETERS:  SpecificFlags       - "Specific" flag byte to be decoded
436  *
437  * RETURN:      None
438  *
439  * DESCRIPTION: Decode the flags specific to IO Address space descriptors
440  *
441  ******************************************************************************/
442
443 static void
444 AcpiDmIoFlags2 (
445         UINT8               SpecificFlags)
446 {
447
448     /* _TTP */
449
450     AcpiOsPrintf (", %s",
451         AcpiGbl_TtpDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 4)]);
452
453     /*
454      * TRS is only used if TTP is TypeTranslation. However, the disassembler
455      * always emits exactly what is in the AML.
456      */
457     AcpiOsPrintf (", %s",
458         AcpiGbl_TrsDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]);
459 }
460
461
462 /*******************************************************************************
463  *
464  * FUNCTION:    AcpiDmMemoryFlags
465  *
466  * PARAMETERS:  Flags               - Flag byte to be decoded
467  *              SpecificFlags       - "Specific" flag byte to be decoded
468  *
469  * RETURN:      None
470  *
471  * DESCRIPTION: Decode flags specific to Memory Address Space descriptors
472  *
473  ******************************************************************************/
474
475 static void
476 AcpiDmMemoryFlags (
477     UINT8                   Flags,
478     UINT8                   SpecificFlags)
479 {
480
481     AcpiOsPrintf ("%s, %s, %s, %s, %s, %s,",
482         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Flags)],
483         AcpiGbl_DecDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 1)],
484         AcpiGbl_MinDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 2)],
485         AcpiGbl_MaxDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 3)],
486         AcpiGbl_MemDecode [ACPI_EXTRACT_2BIT_FLAG (SpecificFlags, 1)],
487         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (SpecificFlags)]);
488 }
489
490
491 /*******************************************************************************
492  *
493  * FUNCTION:    AcpiDmMemoryFlags2
494  *
495  * PARAMETERS:  SpecificFlags       - "Specific" flag byte to be decoded
496  *
497  * RETURN:      None
498  *
499  * DESCRIPTION: Decode flags specific to Memory Address Space descriptors
500  *
501  ******************************************************************************/
502
503 static void
504 AcpiDmMemoryFlags2 (
505     UINT8                   SpecificFlags)
506 {
507
508     AcpiOsPrintf (", %s, %s",
509         AcpiGbl_MtpDecode [ACPI_EXTRACT_2BIT_FLAG (SpecificFlags, 3)],
510         AcpiGbl_TtpDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]);
511 }
512
513
514 /*******************************************************************************
515  *
516  * FUNCTION:    AcpiDmResourceSource
517  *
518  * PARAMETERS:  Resource        - Raw AML descriptor
519  *              MinimumLength   - descriptor length without optional fields
520  *              ResourceLength
521  *
522  * RETURN:      None
523  *
524  * DESCRIPTION: Dump optional ResourceSource fields of an address descriptor
525  *
526  ******************************************************************************/
527
528 static void
529 AcpiDmResourceSource (
530     AML_RESOURCE            *Resource,
531     ACPI_SIZE               MinimumTotalLength,
532     UINT32                  ResourceLength)
533 {
534     UINT8                   *AmlResourceSource;
535     UINT32                  TotalLength;
536
537
538     TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
539
540     /* Check if the optional ResourceSource fields are present */
541
542     if (TotalLength <= MinimumTotalLength)
543     {
544         /* The two optional fields are not used */
545
546         AcpiOsPrintf (",, ");
547         return;
548     }
549
550     /* Get a pointer to the ResourceSource */
551
552     AmlResourceSource = ACPI_ADD_PTR (UINT8, Resource, MinimumTotalLength);
553
554     /*
555      * Always emit the ResourceSourceIndex (Byte)
556      *
557      * NOTE: Some ASL compilers always create a 0 byte (in the AML) for the
558      * Index even if the String does not exist. Although this is in violation
559      * of the ACPI specification, it is very important to emit ASL code that
560      * can be compiled back to the identical AML. There may be fields and/or
561      * indexes into the resource template buffer that are compiled to absolute
562      * offsets, and these will be broken if the AML length is changed.
563      */
564     AcpiOsPrintf ("0x%2.2X,", (UINT32) AmlResourceSource[0]);
565
566     /* Make sure that the ResourceSource string exists before dumping it */
567
568     if (TotalLength > (MinimumTotalLength + 1))
569     {
570         AcpiOsPrintf (" ");
571         AcpiUtPrintString ((char *) &AmlResourceSource[1], ACPI_UINT16_MAX);
572     }
573
574     AcpiOsPrintf (", ");
575 }
576
577
578 /*******************************************************************************
579  *
580  * FUNCTION:    AcpiDmWordDescriptor
581  *
582  * PARAMETERS:  Info                - Extra resource info
583  *              Resource            - Pointer to the resource descriptor
584  *              Length              - Length of the descriptor in bytes
585  *              Level               - Current source code indentation level
586  *
587  * RETURN:      None
588  *
589  * DESCRIPTION: Decode a Word Address Space descriptor
590  *
591  ******************************************************************************/
592
593 void
594 AcpiDmWordDescriptor (
595     ACPI_OP_WALK_INFO       *Info,
596     AML_RESOURCE            *Resource,
597     UINT32                  Length,
598     UINT32                  Level)
599 {
600
601     /* Dump resource name and flags */
602
603     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS16, Level);
604
605     /* Dump the 5 contiguous WORD values */
606
607     AcpiDmAddressFields (&Resource->Address16.Granularity, 16, Level);
608
609     /* The ResourceSource fields are optional */
610
611     AcpiDmIndent (Level + 1);
612     AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS16), Length);
613
614     /* Insert a descriptor name */
615
616     AcpiDmDescriptorName ();
617
618     /* Type-specific flags */
619
620     AcpiDmAddressFlags (Resource);
621     AcpiOsPrintf (")\n");
622 }
623
624
625 /*******************************************************************************
626  *
627  * FUNCTION:    AcpiDmDwordDescriptor
628  *
629  * PARAMETERS:  Info                - Extra resource info
630  *              Resource            - Pointer to the resource descriptor
631  *              Length              - Length of the descriptor in bytes
632  *              Level               - Current source code indentation level
633  *
634  * RETURN:      None
635  *
636  * DESCRIPTION: Decode a DWord Address Space descriptor
637  *
638  ******************************************************************************/
639
640 void
641 AcpiDmDwordDescriptor (
642     ACPI_OP_WALK_INFO       *Info,
643     AML_RESOURCE            *Resource,
644     UINT32                  Length,
645     UINT32                  Level)
646 {
647
648     /* Dump resource name and flags */
649
650     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS32, Level);
651
652     /* Dump the 5 contiguous DWORD values */
653
654     AcpiDmAddressFields (&Resource->Address32.Granularity, 32, Level);
655
656     /* The ResourceSource fields are optional */
657
658     AcpiDmIndent (Level + 1);
659     AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS32), Length);
660
661     /* Insert a descriptor name */
662
663     AcpiDmDescriptorName ();
664
665     /* Type-specific flags */
666
667     AcpiDmAddressFlags (Resource);
668     AcpiOsPrintf (")\n");
669 }
670
671
672 /*******************************************************************************
673  *
674  * FUNCTION:    AcpiDmQwordDescriptor
675  *
676  * PARAMETERS:  Info                - Extra resource info
677  *              Resource            - Pointer to the resource descriptor
678  *              Length              - Length of the descriptor in bytes
679  *              Level               - Current source code indentation level
680  *
681  * RETURN:      None
682  *
683  * DESCRIPTION: Decode a QWord Address Space descriptor
684  *
685  ******************************************************************************/
686
687 void
688 AcpiDmQwordDescriptor (
689     ACPI_OP_WALK_INFO       *Info,
690     AML_RESOURCE            *Resource,
691     UINT32                  Length,
692     UINT32                  Level)
693 {
694
695     /* Dump resource name and flags */
696
697     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS64, Level);
698
699     /* Dump the 5 contiguous QWORD values */
700
701     AcpiDmAddressFields (&Resource->Address64.Granularity, 64, Level);
702
703     /* The ResourceSource fields are optional */
704
705     AcpiDmIndent (Level + 1);
706     AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS64), Length);
707
708     /* Insert a descriptor name */
709
710     AcpiDmDescriptorName ();
711
712     /* Type-specific flags */
713
714     AcpiDmAddressFlags (Resource);
715     AcpiOsPrintf (")\n");
716 }
717
718
719 /*******************************************************************************
720  *
721  * FUNCTION:    AcpiDmExtendedDescriptor
722  *
723  * PARAMETERS:  Info                - Extra resource info
724  *              Resource            - Pointer to the resource descriptor
725  *              Length              - Length of the descriptor in bytes
726  *              Level               - Current source code indentation level
727  *
728  * RETURN:      None
729  *
730  * DESCRIPTION: Decode a Extended Address Space descriptor
731  *
732  ******************************************************************************/
733
734 void
735 AcpiDmExtendedDescriptor (
736     ACPI_OP_WALK_INFO       *Info,
737     AML_RESOURCE            *Resource,
738     UINT32                  Length,
739     UINT32                  Level)
740 {
741
742     /* Dump resource name and flags */
743
744     AcpiDmAddressCommon (
745         Resource, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, Level);
746
747     /* Dump the 5 contiguous QWORD values */
748
749     AcpiDmAddressFields (&Resource->ExtAddress64.Granularity, 64, Level);
750
751     /* Extra field for this descriptor only */
752
753     AcpiDmIndent (Level + 1);
754     AcpiDmDumpInteger64 (Resource->ExtAddress64.TypeSpecific,
755         "Type-Specific Attributes");
756
757     /* Insert a descriptor name */
758
759     AcpiDmIndent (Level + 1);
760     AcpiDmDescriptorName ();
761
762     /* Type-specific flags */
763
764     AcpiDmAddressFlags (Resource);
765     AcpiOsPrintf (")\n");
766 }
767
768
769 /*******************************************************************************
770  *
771  * FUNCTION:    AcpiDmMemory24Descriptor
772  *
773  * PARAMETERS:  Info                - Extra resource info
774  *              Resource            - Pointer to the resource descriptor
775  *              Length              - Length of the descriptor in bytes
776  *              Level               - Current source code indentation level
777  *
778  * RETURN:      None
779  *
780  * DESCRIPTION: Decode a Memory24 descriptor
781  *
782  ******************************************************************************/
783
784 void
785 AcpiDmMemory24Descriptor (
786     ACPI_OP_WALK_INFO       *Info,
787     AML_RESOURCE            *Resource,
788     UINT32                  Length,
789     UINT32                  Level)
790 {
791
792     /* Dump name and read/write flag */
793
794     AcpiDmIndent (Level);
795     AcpiOsPrintf ("Memory24 (%s,\n",
796         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->Memory24.Flags)]);
797
798     /* Dump the 4 contiguous WORD values */
799
800     AcpiDmMemoryFields (&Resource->Memory24.Minimum, 16, Level);
801
802     /* Insert a descriptor name */
803
804     AcpiDmIndent (Level + 1);
805     AcpiDmDescriptorName ();
806     AcpiOsPrintf (")\n");
807 }
808
809
810 /*******************************************************************************
811  *
812  * FUNCTION:    AcpiDmMemory32Descriptor
813  *
814  * PARAMETERS:  Info                - Extra resource info
815  *              Resource            - Pointer to the resource descriptor
816  *              Length              - Length of the descriptor in bytes
817  *              Level               - Current source code indentation level
818  *
819  * RETURN:      None
820  *
821  * DESCRIPTION: Decode a Memory32 descriptor
822  *
823  ******************************************************************************/
824
825 void
826 AcpiDmMemory32Descriptor (
827     ACPI_OP_WALK_INFO       *Info,
828     AML_RESOURCE            *Resource,
829     UINT32                  Length,
830     UINT32                  Level)
831 {
832
833     /* Dump name and read/write flag */
834
835     AcpiDmIndent (Level);
836     AcpiOsPrintf ("Memory32 (%s,\n",
837         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->Memory32.Flags)]);
838
839     /* Dump the 4 contiguous DWORD values */
840
841     AcpiDmMemoryFields (&Resource->Memory32.Minimum, 32, Level);
842
843     /* Insert a descriptor name */
844
845     AcpiDmIndent (Level + 1);
846     AcpiDmDescriptorName ();
847     AcpiOsPrintf (")\n");
848 }
849
850
851 /*******************************************************************************
852  *
853  * FUNCTION:    AcpiDmFixedMemory32Descriptor
854  *
855  * PARAMETERS:  Info                - Extra resource info
856  *              Resource            - Pointer to the resource descriptor
857  *              Length              - Length of the descriptor in bytes
858  *              Level               - Current source code indentation level
859  *
860  * RETURN:      None
861  *
862  * DESCRIPTION: Decode a Fixed Memory32 descriptor
863  *
864  ******************************************************************************/
865
866 void
867 AcpiDmFixedMemory32Descriptor (
868     ACPI_OP_WALK_INFO       *Info,
869     AML_RESOURCE            *Resource,
870     UINT32                  Length,
871     UINT32                  Level)
872 {
873
874     /* Dump name and read/write flag */
875
876     AcpiDmIndent (Level);
877     AcpiOsPrintf ("Memory32Fixed (%s,\n",
878         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->FixedMemory32.Flags)]);
879
880     AcpiDmIndent (Level + 1);
881     AcpiDmDumpInteger32 (Resource->FixedMemory32.Address,
882         "Address Base");
883
884     AcpiDmIndent (Level + 1);
885     AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength,
886         "Address Length");
887
888     /* Insert a descriptor name */
889
890     AcpiDmIndent (Level + 1);
891     AcpiDmDescriptorName ();
892     AcpiOsPrintf (")\n");
893 }
894
895
896 /*******************************************************************************
897  *
898  * FUNCTION:    AcpiDmGenericRegisterDescriptor
899  *
900  * PARAMETERS:  Info                - Extra resource info
901  *              Resource            - Pointer to the resource descriptor
902  *              Length              - Length of the descriptor in bytes
903  *              Level               - Current source code indentation level
904  *
905  * RETURN:      None
906  *
907  * DESCRIPTION: Decode a Generic Register descriptor
908  *
909  ******************************************************************************/
910
911 void
912 AcpiDmGenericRegisterDescriptor (
913     ACPI_OP_WALK_INFO       *Info,
914     AML_RESOURCE            *Resource,
915     UINT32                  Length,
916     UINT32                  Level)
917 {
918
919     AcpiDmIndent (Level);
920     AcpiOsPrintf ("Register (");
921     AcpiDmAddressSpace (Resource->GenericReg.AddressSpaceId);
922     AcpiOsPrintf ("\n");
923
924     AcpiDmIndent (Level + 1);
925     AcpiDmDumpInteger8 (Resource->GenericReg.BitWidth, "Bit Width");
926
927     AcpiDmIndent (Level + 1);
928     AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Bit Offset");
929
930     AcpiDmIndent (Level + 1);
931     AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address");
932
933     /* Optional field for ACPI 3.0 */
934
935     AcpiDmIndent (Level + 1);
936     if (Resource->GenericReg.AccessSize)
937     {
938         AcpiOsPrintf ("0x%2.2X,               // %s\n",
939             Resource->GenericReg.AccessSize, "Access Size");
940         AcpiDmIndent (Level + 1);
941     }
942     else
943     {
944         AcpiOsPrintf (",");
945     }
946
947     /* DescriptorName was added for ACPI 3.0+ */
948
949     AcpiDmDescriptorName ();
950     AcpiOsPrintf (")\n");
951 }
952
953
954 /*******************************************************************************
955  *
956  * FUNCTION:    AcpiDmInterruptDescriptor
957  *
958  * PARAMETERS:  Info                - Extra resource info
959  *              Resource            - Pointer to the resource descriptor
960  *              Length              - Length of the descriptor in bytes
961  *              Level               - Current source code indentation level
962  *
963  * RETURN:      None
964  *
965  * DESCRIPTION: Decode a extended Interrupt descriptor
966  *
967  ******************************************************************************/
968
969 void
970 AcpiDmInterruptDescriptor (
971     ACPI_OP_WALK_INFO       *Info,
972     AML_RESOURCE            *Resource,
973     UINT32                  Length,
974     UINT32                  Level)
975 {
976     UINT32                  i;
977
978
979     AcpiDmIndent (Level);
980     AcpiOsPrintf ("Interrupt (%s, %s, %s, %s, ",
981         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->ExtendedIrq.Flags)],
982         AcpiGbl_HeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->ExtendedIrq.Flags, 1)],
983         AcpiGbl_LlDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->ExtendedIrq.Flags, 2)],
984         AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->ExtendedIrq.Flags, 3)]);
985
986     /*
987      * The ResourceSource fields are optional and appear after the interrupt
988      * list. Must compute length based on length of the list. First xrupt
989      * is included in the struct (reason for -1 below)
990      */
991     AcpiDmResourceSource (Resource,
992         sizeof (AML_RESOURCE_EXTENDED_IRQ) +
993             ((UINT32) Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32),
994         Resource->ExtendedIrq.ResourceLength);
995
996     /* Insert a descriptor name */
997
998     AcpiDmDescriptorName ();
999     AcpiOsPrintf (")\n");
1000
1001     /* Dump the interrupt list */
1002
1003     AcpiDmIndent (Level);
1004     AcpiOsPrintf ("{\n");
1005     for (i = 0; i < Resource->ExtendedIrq.InterruptCount; i++)
1006     {
1007         AcpiDmIndent (Level + 1);
1008         AcpiOsPrintf ("0x%8.8X,\n",
1009             (UINT32) Resource->ExtendedIrq.Interrupts[i]);
1010     }
1011
1012     AcpiDmIndent (Level);
1013     AcpiOsPrintf ("}\n");
1014 }
1015
1016
1017 /*******************************************************************************
1018  *
1019  * FUNCTION:    AcpiDmVendorCommon
1020  *
1021  * PARAMETERS:  Name                - Descriptor name suffix
1022  *              ByteData            - Pointer to the vendor byte data
1023  *              Length              - Length of the byte data
1024  *              Level               - Current source code indentation level
1025  *
1026  * RETURN:      None
1027  *
1028  * DESCRIPTION: Decode a Vendor descriptor, both Large and Small
1029  *
1030  ******************************************************************************/
1031
1032 void
1033 AcpiDmVendorCommon (
1034     const char              *Name,
1035     UINT8                   *ByteData,
1036     UINT32                  Length,
1037     UINT32                  Level)
1038 {
1039
1040     /* Dump macro name */
1041
1042     AcpiDmIndent (Level);
1043     AcpiOsPrintf ("Vendor%s (", Name);
1044
1045     /* Insert a descriptor name */
1046
1047     AcpiDmDescriptorName ();
1048     AcpiOsPrintf (")      // Length = 0x%.2X\n", Length);
1049
1050     /* Dump the vendor bytes */
1051
1052     AcpiDmIndent (Level);
1053     AcpiOsPrintf ("{\n");
1054
1055     AcpiDmDisasmByteList (Level + 1, ByteData, Length);
1056
1057     AcpiDmIndent (Level);
1058     AcpiOsPrintf ("}\n");
1059 }
1060
1061
1062 /*******************************************************************************
1063  *
1064  * FUNCTION:    AcpiDmVendorLargeDescriptor
1065  *
1066  * PARAMETERS:  Info                - Extra resource info
1067  *              Resource            - Pointer to the resource descriptor
1068  *              Length              - Length of the descriptor in bytes
1069  *              Level               - Current source code indentation level
1070  *
1071  * RETURN:      None
1072  *
1073  * DESCRIPTION: Decode a Vendor Large descriptor
1074  *
1075  ******************************************************************************/
1076
1077 void
1078 AcpiDmVendorLargeDescriptor (
1079     ACPI_OP_WALK_INFO       *Info,
1080     AML_RESOURCE            *Resource,
1081     UINT32                  Length,
1082     UINT32                  Level)
1083 {
1084
1085     AcpiDmVendorCommon ("Long ",
1086         ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_LARGE_HEADER)),
1087         Length, Level);
1088 }
1089
1090 #endif