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