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