Merge branch 'vendor/DHCPCD'
[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  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151
152 #include "acpi.h"
153 #include "accommon.h"
154 #include "acdisasm.h"
155
156
157 #ifdef ACPI_DISASSEMBLER
158
159 #define _COMPONENT          ACPI_CA_DEBUGGER
160         ACPI_MODULE_NAME    ("dbresrcl")
161
162
163 /* Common names for address and memory descriptors */
164
165 static const char           *AcpiDmAddressNames[] =
166 {
167     "Granularity",
168     "Range Minimum",
169     "Range Maximum",
170     "Translation Offset",
171     "Length"
172 };
173
174 static const char           *AcpiDmMemoryNames[] =
175 {
176     "Range Minimum",
177     "Range Maximum",
178     "Alignment",
179     "Length"
180 };
181
182
183 /* Local prototypes */
184
185 static void
186 AcpiDmSpaceFlags (
187         UINT8               Flags);
188
189 static void
190 AcpiDmIoFlags (
191         UINT8               Flags);
192
193 static void
194 AcpiDmIoFlags2 (
195         UINT8               SpecificFlags);
196
197 static void
198 AcpiDmMemoryFlags (
199     UINT8                   Flags,
200     UINT8                   SpecificFlags);
201
202 static void
203 AcpiDmMemoryFlags2 (
204     UINT8                   SpecificFlags);
205
206 static void
207 AcpiDmResourceSource (
208     AML_RESOURCE            *Resource,
209     ACPI_SIZE               MinimumLength,
210     UINT32                  Length);
211
212 static void
213 AcpiDmAddressFields (
214     void                    *Source,
215     UINT8                   Type,
216     UINT32                  Level);
217
218 static void
219 AcpiDmAddressPrefix (
220     UINT8                   Type);
221
222 static void
223 AcpiDmAddressCommon (
224     AML_RESOURCE            *Resource,
225     UINT8                   Type,
226     UINT32                  Level);
227
228 static void
229 AcpiDmAddressFlags (
230     AML_RESOURCE            *Resource);
231
232
233 /*******************************************************************************
234  *
235  * FUNCTION:    AcpiDmMemoryFields
236  *
237  * PARAMETERS:  Source              - Pointer to the contiguous data fields
238  *              Type                - 16 or 32 (bit)
239  *              Level               - Current source code indentation level
240  *
241  * RETURN:      None
242  *
243  * DESCRIPTION: Decode fields common to Memory24 and Memory32 descriptors
244  *
245  ******************************************************************************/
246
247 static void
248 AcpiDmMemoryFields (
249     void                    *Source,
250     UINT8                   Type,
251     UINT32                  Level)
252 {
253     UINT32                  i;
254
255
256     for (i = 0; i < 4; i++)
257     {
258         AcpiDmIndent (Level + 1);
259
260         switch (Type)
261         {
262         case 16:
263
264             AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
265                 AcpiDmMemoryNames[i]);
266             break;
267
268         case 32:
269
270             AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
271                 AcpiDmMemoryNames[i]);
272             break;
273
274         default:
275
276             return;
277         }
278     }
279 }
280
281
282 /*******************************************************************************
283  *
284  * FUNCTION:    AcpiDmAddressFields
285  *
286  * PARAMETERS:  Source              - Pointer to the contiguous data fields
287  *              Type                - 16, 32, or 64 (bit)
288  *              Level               - Current source code indentation level
289  *
290  * RETURN:      None
291  *
292  * DESCRIPTION: Decode fields common to address descriptors
293  *
294  ******************************************************************************/
295
296 static void
297 AcpiDmAddressFields (
298     void                    *Source,
299     UINT8                   Type,
300     UINT32                  Level)
301 {
302     UINT32                  i;
303
304
305     AcpiOsPrintf ("\n");
306
307     for (i = 0; i < 5; i++)
308     {
309         AcpiDmIndent (Level + 1);
310
311         switch (Type)
312         {
313         case 16:
314
315             AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
316                 AcpiDmAddressNames[i]);
317             break;
318
319         case 32:
320
321             AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
322                 AcpiDmAddressNames[i]);
323             break;
324
325         case 64:
326
327             AcpiDmDumpInteger64 (ACPI_CAST_PTR (UINT64, Source)[i],
328                 AcpiDmAddressNames[i]);
329             break;
330
331         default:
332
333             return;
334         }
335     }
336 }
337
338
339 /*******************************************************************************
340  *
341  * FUNCTION:    AcpiDmAddressPrefix
342  *
343  * PARAMETERS:  Type                - Descriptor type
344  *
345  * RETURN:      None
346  *
347  * DESCRIPTION: Emit name prefix representing the address descriptor type
348  *
349  ******************************************************************************/
350
351 static void
352 AcpiDmAddressPrefix (
353     UINT8                   Type)
354 {
355
356     switch (Type)
357     {
358     case ACPI_RESOURCE_TYPE_ADDRESS16:
359
360         AcpiOsPrintf ("Word");
361         break;
362
363     case ACPI_RESOURCE_TYPE_ADDRESS32:
364
365         AcpiOsPrintf ("DWord");
366         break;
367
368     case ACPI_RESOURCE_TYPE_ADDRESS64:
369
370         AcpiOsPrintf ("QWord");
371         break;
372
373     case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
374
375         AcpiOsPrintf ("Extended");
376         break;
377
378     default:
379
380         return;
381     }
382 }
383
384
385 /*******************************************************************************
386  *
387  * FUNCTION:    AcpiDmAddressCommon
388  *
389  * PARAMETERS:  Resource            - Raw AML descriptor
390  *              Type                - Descriptor type
391  *              Level               - Current source code indentation level
392  *
393  * RETURN:      None
394  *
395  * DESCRIPTION: Emit common name and flag fields common to address descriptors
396  *
397  ******************************************************************************/
398
399 static void
400 AcpiDmAddressCommon (
401     AML_RESOURCE            *Resource,
402     UINT8                   Type,
403     UINT32                  Level)
404 {
405     UINT8                   ResourceType;
406     UINT8                   SpecificFlags;
407     UINT8                   Flags;
408
409
410     ResourceType = Resource->Address.ResourceType;
411     SpecificFlags = Resource->Address.SpecificFlags;
412     Flags = Resource->Address.Flags;
413
414     AcpiDmIndent (Level);
415
416     /* Validate ResourceType */
417
418     if ((ResourceType > 2) && (ResourceType < 0xC0))
419     {
420         AcpiOsPrintf (
421             "/**** Invalid Resource Type: 0x%X ****/", ResourceType);
422         return;
423     }
424
425     /* Prefix is either Word, DWord, QWord, or Extended */
426
427     AcpiDmAddressPrefix (Type);
428
429     /* Resource Types above 0xC0 are vendor-defined */
430
431     if (ResourceType > 2)
432     {
433         AcpiOsPrintf ("Space (0x%2.2X, ", ResourceType);
434         AcpiDmSpaceFlags (Flags);
435         AcpiOsPrintf (" 0x%2.2X,", SpecificFlags);
436         return;
437     }
438
439     /* This is either a Memory, IO, or BusNumber descriptor (0,1,2) */
440
441     AcpiOsPrintf ("%s (",
442         AcpiGbl_WordDecode [ACPI_GET_2BIT_FLAG (ResourceType)]);
443
444     /* Decode the general and type-specific flags */
445
446     if (ResourceType == ACPI_MEMORY_RANGE)
447     {
448         AcpiDmMemoryFlags (Flags, SpecificFlags);
449     }
450     else /* IO range or BusNumberRange */
451     {
452         AcpiDmIoFlags (Flags);
453         if (ResourceType == ACPI_IO_RANGE)
454         {
455             AcpiOsPrintf (" %s,",
456                 AcpiGbl_RngDecode [ACPI_GET_2BIT_FLAG (SpecificFlags)]);
457         }
458     }
459 }
460
461
462 /*******************************************************************************
463  *
464  * FUNCTION:    AcpiDmAddressFlags
465  *
466  * PARAMETERS:  Resource        - Raw AML descriptor
467  *
468  * RETURN:      None
469  *
470  * DESCRIPTION: Emit flags common to address descriptors
471  *
472  ******************************************************************************/
473
474 static void
475 AcpiDmAddressFlags (
476     AML_RESOURCE            *Resource)
477 {
478
479     if (Resource->Address.ResourceType == ACPI_IO_RANGE)
480     {
481         AcpiDmIoFlags2 (Resource->Address.SpecificFlags);
482     }
483     else if (Resource->Address.ResourceType == ACPI_MEMORY_RANGE)
484     {
485         AcpiDmMemoryFlags2 (Resource->Address.SpecificFlags);
486     }
487 }
488
489
490 /*******************************************************************************
491  *
492  * FUNCTION:    AcpiDmSpaceFlags
493  *
494  * PARAMETERS:  Flags               - Flag byte to be decoded
495  *
496  * RETURN:      None
497  *
498  * DESCRIPTION: Decode the flags specific to Space Address space descriptors
499  *
500  ******************************************************************************/
501
502 static void
503 AcpiDmSpaceFlags (
504     UINT8                   Flags)
505 {
506
507     AcpiOsPrintf ("%s, %s, %s, %s,",
508         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Flags)],
509         AcpiGbl_DecDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 1)],
510         AcpiGbl_MinDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 2)],
511         AcpiGbl_MaxDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 3)]);
512 }
513
514
515 /*******************************************************************************
516  *
517  * FUNCTION:    AcpiDmIoFlags
518  *
519  * PARAMETERS:  Flags               - Flag byte to be decoded
520  *
521  * RETURN:      None
522  *
523  * DESCRIPTION: Decode the flags specific to IO Address space descriptors
524  *
525  ******************************************************************************/
526
527 static void
528 AcpiDmIoFlags (
529         UINT8               Flags)
530 {
531     AcpiOsPrintf ("%s, %s, %s, %s,",
532         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Flags)],
533         AcpiGbl_MinDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 2)],
534         AcpiGbl_MaxDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 3)],
535         AcpiGbl_DecDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 1)]);
536 }
537
538
539 /*******************************************************************************
540  *
541  * FUNCTION:    AcpiDmIoFlags2
542  *
543  * PARAMETERS:  SpecificFlags       - "Specific" flag byte to be decoded
544  *
545  * RETURN:      None
546  *
547  * DESCRIPTION: Decode the flags specific to IO Address space descriptors
548  *
549  ******************************************************************************/
550
551 static void
552 AcpiDmIoFlags2 (
553         UINT8               SpecificFlags)
554 {
555
556     /* _TTP */
557
558     AcpiOsPrintf (", %s",
559         AcpiGbl_TtpDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 4)]);
560
561     /*
562      * TRS is only used if TTP is TypeTranslation. However, the disassembler
563      * always emits exactly what is in the AML.
564      */
565     AcpiOsPrintf (", %s",
566         AcpiGbl_TrsDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]);
567 }
568
569
570 /*******************************************************************************
571  *
572  * FUNCTION:    AcpiDmMemoryFlags
573  *
574  * PARAMETERS:  Flags               - Flag byte to be decoded
575  *              SpecificFlags       - "Specific" flag byte to be decoded
576  *
577  * RETURN:      None
578  *
579  * DESCRIPTION: Decode flags specific to Memory Address Space descriptors
580  *
581  ******************************************************************************/
582
583 static void
584 AcpiDmMemoryFlags (
585     UINT8                   Flags,
586     UINT8                   SpecificFlags)
587 {
588
589     AcpiOsPrintf ("%s, %s, %s, %s, %s, %s,",
590         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Flags)],
591         AcpiGbl_DecDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 1)],
592         AcpiGbl_MinDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 2)],
593         AcpiGbl_MaxDecode [ACPI_EXTRACT_1BIT_FLAG (Flags, 3)],
594         AcpiGbl_MemDecode [ACPI_EXTRACT_2BIT_FLAG (SpecificFlags, 1)],
595         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (SpecificFlags)]);
596 }
597
598
599 /*******************************************************************************
600  *
601  * FUNCTION:    AcpiDmMemoryFlags2
602  *
603  * PARAMETERS:  SpecificFlags       - "Specific" flag byte to be decoded
604  *
605  * RETURN:      None
606  *
607  * DESCRIPTION: Decode flags specific to Memory Address Space descriptors
608  *
609  ******************************************************************************/
610
611 static void
612 AcpiDmMemoryFlags2 (
613     UINT8                   SpecificFlags)
614 {
615
616     AcpiOsPrintf (", %s, %s",
617         AcpiGbl_MtpDecode [ACPI_EXTRACT_2BIT_FLAG (SpecificFlags, 3)],
618         AcpiGbl_TtpDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]);
619 }
620
621
622 /*******************************************************************************
623  *
624  * FUNCTION:    AcpiDmResourceSource
625  *
626  * PARAMETERS:  Resource        - Raw AML descriptor
627  *              MinimumLength   - descriptor length without optional fields
628  *              ResourceLength
629  *
630  * RETURN:      None
631  *
632  * DESCRIPTION: Dump optional ResourceSource fields of an address descriptor
633  *
634  ******************************************************************************/
635
636 static void
637 AcpiDmResourceSource (
638     AML_RESOURCE            *Resource,
639     ACPI_SIZE               MinimumTotalLength,
640     UINT32                  ResourceLength)
641 {
642     UINT8                   *AmlResourceSource;
643     UINT32                  TotalLength;
644
645
646     TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
647
648     /* Check if the optional ResourceSource fields are present */
649
650     if (TotalLength <= MinimumTotalLength)
651     {
652         /* The two optional fields are not used */
653
654         AcpiOsPrintf (",, ");
655         return;
656     }
657
658     /* Get a pointer to the ResourceSource */
659
660     AmlResourceSource = ACPI_ADD_PTR (UINT8, Resource, MinimumTotalLength);
661
662     /*
663      * Always emit the ResourceSourceIndex (Byte)
664      *
665      * NOTE: Some ASL compilers always create a 0 byte (in the AML) for the
666      * Index even if the String does not exist. Although this is in violation
667      * of the ACPI specification, it is very important to emit ASL code that
668      * can be compiled back to the identical AML. There may be fields and/or
669      * indexes into the resource template buffer that are compiled to absolute
670      * offsets, and these will be broken if the AML length is changed.
671      */
672     AcpiOsPrintf ("0x%2.2X,", (UINT32) AmlResourceSource[0]);
673
674     /* Make sure that the ResourceSource string exists before dumping it */
675
676     if (TotalLength > (MinimumTotalLength + 1))
677     {
678         AcpiOsPrintf (" ");
679         AcpiUtPrintString ((char *) &AmlResourceSource[1], ACPI_UINT16_MAX);
680     }
681
682     AcpiOsPrintf (", ");
683 }
684
685
686 /*******************************************************************************
687  *
688  * FUNCTION:    AcpiDmWordDescriptor
689  *
690  * PARAMETERS:  Info                - Extra resource info
691  *              Resource            - Pointer to the resource descriptor
692  *              Length              - Length of the descriptor in bytes
693  *              Level               - Current source code indentation level
694  *
695  * RETURN:      None
696  *
697  * DESCRIPTION: Decode a Word Address Space descriptor
698  *
699  ******************************************************************************/
700
701 void
702 AcpiDmWordDescriptor (
703     ACPI_OP_WALK_INFO       *Info,
704     AML_RESOURCE            *Resource,
705     UINT32                  Length,
706     UINT32                  Level)
707 {
708
709     /* Dump resource name and flags */
710
711     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS16, Level);
712
713     /* Dump the 5 contiguous WORD values */
714
715     AcpiDmAddressFields (&Resource->Address16.Granularity, 16, Level);
716
717     /* The ResourceSource fields are optional */
718
719     AcpiDmIndent (Level + 1);
720     AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS16), Length);
721
722     /* Insert a descriptor name */
723
724     AcpiDmDescriptorName ();
725
726     /* Type-specific flags */
727
728     AcpiDmAddressFlags (Resource);
729     AcpiOsPrintf (")\n");
730 }
731
732
733 /*******************************************************************************
734  *
735  * FUNCTION:    AcpiDmDwordDescriptor
736  *
737  * PARAMETERS:  Info                - Extra resource info
738  *              Resource            - Pointer to the resource descriptor
739  *              Length              - Length of the descriptor in bytes
740  *              Level               - Current source code indentation level
741  *
742  * RETURN:      None
743  *
744  * DESCRIPTION: Decode a DWord Address Space descriptor
745  *
746  ******************************************************************************/
747
748 void
749 AcpiDmDwordDescriptor (
750     ACPI_OP_WALK_INFO       *Info,
751     AML_RESOURCE            *Resource,
752     UINT32                  Length,
753     UINT32                  Level)
754 {
755
756     /* Dump resource name and flags */
757
758     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS32, Level);
759
760     /* Dump the 5 contiguous DWORD values */
761
762     AcpiDmAddressFields (&Resource->Address32.Granularity, 32, Level);
763
764     /* The ResourceSource fields are optional */
765
766     AcpiDmIndent (Level + 1);
767     AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS32), Length);
768
769     /* Insert a descriptor name */
770
771     AcpiDmDescriptorName ();
772
773     /* Type-specific flags */
774
775     AcpiDmAddressFlags (Resource);
776     AcpiOsPrintf (")\n");
777 }
778
779
780 /*******************************************************************************
781  *
782  * FUNCTION:    AcpiDmQwordDescriptor
783  *
784  * PARAMETERS:  Info                - Extra resource info
785  *              Resource            - Pointer to the resource descriptor
786  *              Length              - Length of the descriptor in bytes
787  *              Level               - Current source code indentation level
788  *
789  * RETURN:      None
790  *
791  * DESCRIPTION: Decode a QWord Address Space descriptor
792  *
793  ******************************************************************************/
794
795 void
796 AcpiDmQwordDescriptor (
797     ACPI_OP_WALK_INFO       *Info,
798     AML_RESOURCE            *Resource,
799     UINT32                  Length,
800     UINT32                  Level)
801 {
802
803     /* Dump resource name and flags */
804
805     AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS64, Level);
806
807     /* Dump the 5 contiguous QWORD values */
808
809     AcpiDmAddressFields (&Resource->Address64.Granularity, 64, Level);
810
811     /* The ResourceSource fields are optional */
812
813     AcpiDmIndent (Level + 1);
814     AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS64), Length);
815
816     /* Insert a descriptor name */
817
818     AcpiDmDescriptorName ();
819
820     /* Type-specific flags */
821
822     AcpiDmAddressFlags (Resource);
823     AcpiOsPrintf (")\n");
824 }
825
826
827 /*******************************************************************************
828  *
829  * FUNCTION:    AcpiDmExtendedDescriptor
830  *
831  * PARAMETERS:  Info                - Extra resource info
832  *              Resource            - Pointer to the resource descriptor
833  *              Length              - Length of the descriptor in bytes
834  *              Level               - Current source code indentation level
835  *
836  * RETURN:      None
837  *
838  * DESCRIPTION: Decode a Extended Address Space descriptor
839  *
840  ******************************************************************************/
841
842 void
843 AcpiDmExtendedDescriptor (
844     ACPI_OP_WALK_INFO       *Info,
845     AML_RESOURCE            *Resource,
846     UINT32                  Length,
847     UINT32                  Level)
848 {
849
850     /* Dump resource name and flags */
851
852     AcpiDmAddressCommon (
853         Resource, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, Level);
854
855     /* Dump the 5 contiguous QWORD values */
856
857     AcpiDmAddressFields (&Resource->ExtAddress64.Granularity, 64, Level);
858
859     /* Extra field for this descriptor only */
860
861     AcpiDmIndent (Level + 1);
862     AcpiDmDumpInteger64 (Resource->ExtAddress64.TypeSpecific,
863         "Type-Specific Attributes");
864
865     /* Insert a descriptor name */
866
867     AcpiDmIndent (Level + 1);
868     AcpiDmDescriptorName ();
869
870     /* Type-specific flags */
871
872     AcpiDmAddressFlags (Resource);
873     AcpiOsPrintf (")\n");
874 }
875
876
877 /*******************************************************************************
878  *
879  * FUNCTION:    AcpiDmMemory24Descriptor
880  *
881  * PARAMETERS:  Info                - Extra resource info
882  *              Resource            - Pointer to the resource descriptor
883  *              Length              - Length of the descriptor in bytes
884  *              Level               - Current source code indentation level
885  *
886  * RETURN:      None
887  *
888  * DESCRIPTION: Decode a Memory24 descriptor
889  *
890  ******************************************************************************/
891
892 void
893 AcpiDmMemory24Descriptor (
894     ACPI_OP_WALK_INFO       *Info,
895     AML_RESOURCE            *Resource,
896     UINT32                  Length,
897     UINT32                  Level)
898 {
899
900     /* Dump name and read/write flag */
901
902     AcpiDmIndent (Level);
903     AcpiOsPrintf ("Memory24 (%s,\n",
904         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->Memory24.Flags)]);
905
906     /* Dump the 4 contiguous WORD values */
907
908     AcpiDmMemoryFields (&Resource->Memory24.Minimum, 16, Level);
909
910     /* Insert a descriptor name */
911
912     AcpiDmIndent (Level + 1);
913     AcpiDmDescriptorName ();
914     AcpiOsPrintf (")\n");
915 }
916
917
918 /*******************************************************************************
919  *
920  * FUNCTION:    AcpiDmMemory32Descriptor
921  *
922  * PARAMETERS:  Info                - Extra resource info
923  *              Resource            - Pointer to the resource descriptor
924  *              Length              - Length of the descriptor in bytes
925  *              Level               - Current source code indentation level
926  *
927  * RETURN:      None
928  *
929  * DESCRIPTION: Decode a Memory32 descriptor
930  *
931  ******************************************************************************/
932
933 void
934 AcpiDmMemory32Descriptor (
935     ACPI_OP_WALK_INFO       *Info,
936     AML_RESOURCE            *Resource,
937     UINT32                  Length,
938     UINT32                  Level)
939 {
940
941     /* Dump name and read/write flag */
942
943     AcpiDmIndent (Level);
944     AcpiOsPrintf ("Memory32 (%s,\n",
945         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->Memory32.Flags)]);
946
947     /* Dump the 4 contiguous DWORD values */
948
949     AcpiDmMemoryFields (&Resource->Memory32.Minimum, 32, Level);
950
951     /* Insert a descriptor name */
952
953     AcpiDmIndent (Level + 1);
954     AcpiDmDescriptorName ();
955     AcpiOsPrintf (")\n");
956 }
957
958
959 /*******************************************************************************
960  *
961  * FUNCTION:    AcpiDmFixedMemory32Descriptor
962  *
963  * PARAMETERS:  Info                - Extra resource info
964  *              Resource            - Pointer to the resource descriptor
965  *              Length              - Length of the descriptor in bytes
966  *              Level               - Current source code indentation level
967  *
968  * RETURN:      None
969  *
970  * DESCRIPTION: Decode a Fixed Memory32 descriptor
971  *
972  ******************************************************************************/
973
974 void
975 AcpiDmFixedMemory32Descriptor (
976     ACPI_OP_WALK_INFO       *Info,
977     AML_RESOURCE            *Resource,
978     UINT32                  Length,
979     UINT32                  Level)
980 {
981
982     /* Dump name and read/write flag */
983
984     AcpiDmIndent (Level);
985     AcpiOsPrintf ("Memory32Fixed (%s,\n",
986         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->FixedMemory32.Flags)]);
987
988     AcpiDmIndent (Level + 1);
989     AcpiDmDumpInteger32 (Resource->FixedMemory32.Address,
990         "Address Base");
991
992     AcpiDmIndent (Level + 1);
993     AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength,
994         "Address Length");
995
996     /* Insert a descriptor name */
997
998     AcpiDmIndent (Level + 1);
999     AcpiDmDescriptorName ();
1000     AcpiOsPrintf (")\n");
1001 }
1002
1003
1004 /*******************************************************************************
1005  *
1006  * FUNCTION:    AcpiDmGenericRegisterDescriptor
1007  *
1008  * PARAMETERS:  Info                - Extra resource info
1009  *              Resource            - Pointer to the resource descriptor
1010  *              Length              - Length of the descriptor in bytes
1011  *              Level               - Current source code indentation level
1012  *
1013  * RETURN:      None
1014  *
1015  * DESCRIPTION: Decode a Generic Register descriptor
1016  *
1017  ******************************************************************************/
1018
1019 void
1020 AcpiDmGenericRegisterDescriptor (
1021     ACPI_OP_WALK_INFO       *Info,
1022     AML_RESOURCE            *Resource,
1023     UINT32                  Length,
1024     UINT32                  Level)
1025 {
1026
1027     AcpiDmIndent (Level);
1028     AcpiOsPrintf ("Register (");
1029     AcpiDmAddressSpace (Resource->GenericReg.AddressSpaceId);
1030     AcpiOsPrintf ("\n");
1031
1032     AcpiDmIndent (Level + 1);
1033     AcpiDmDumpInteger8 (Resource->GenericReg.BitWidth, "Bit Width");
1034
1035     AcpiDmIndent (Level + 1);
1036     AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Bit Offset");
1037
1038     AcpiDmIndent (Level + 1);
1039     AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address");
1040
1041     /* Optional field for ACPI 3.0 */
1042
1043     AcpiDmIndent (Level + 1);
1044     if (Resource->GenericReg.AccessSize)
1045     {
1046         AcpiOsPrintf ("0x%2.2X,               // %s\n",
1047             Resource->GenericReg.AccessSize, "Access Size");
1048         AcpiDmIndent (Level + 1);
1049     }
1050     else
1051     {
1052         AcpiOsPrintf (",");
1053     }
1054
1055     /* DescriptorName was added for ACPI 3.0+ */
1056
1057     AcpiDmDescriptorName ();
1058     AcpiOsPrintf (")\n");
1059 }
1060
1061
1062 /*******************************************************************************
1063  *
1064  * FUNCTION:    AcpiDmInterruptDescriptor
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 extended Interrupt descriptor
1074  *
1075  ******************************************************************************/
1076
1077 void
1078 AcpiDmInterruptDescriptor (
1079     ACPI_OP_WALK_INFO       *Info,
1080     AML_RESOURCE            *Resource,
1081     UINT32                  Length,
1082     UINT32                  Level)
1083 {
1084     UINT32                  i;
1085
1086
1087     AcpiDmIndent (Level);
1088     AcpiOsPrintf ("Interrupt (%s, %s, %s, %s, ",
1089         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->ExtendedIrq.Flags)],
1090         AcpiGbl_HeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->ExtendedIrq.Flags, 1)],
1091         AcpiGbl_LlDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->ExtendedIrq.Flags, 2)],
1092         AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->ExtendedIrq.Flags, 3)]);
1093
1094     /*
1095      * The ResourceSource fields are optional and appear after the interrupt
1096      * list. Must compute length based on length of the list. First xrupt
1097      * is included in the struct (reason for -1 below)
1098      */
1099     AcpiDmResourceSource (Resource,
1100         sizeof (AML_RESOURCE_EXTENDED_IRQ) +
1101             ((UINT32) Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32),
1102         Resource->ExtendedIrq.ResourceLength);
1103
1104     /* Insert a descriptor name */
1105
1106     AcpiDmDescriptorName ();
1107     AcpiOsPrintf (")\n");
1108
1109     /* Dump the interrupt list */
1110
1111     AcpiDmIndent (Level);
1112     AcpiOsPrintf ("{\n");
1113     for (i = 0; i < Resource->ExtendedIrq.InterruptCount; i++)
1114     {
1115         AcpiDmIndent (Level + 1);
1116         AcpiOsPrintf ("0x%8.8X,\n",
1117             (UINT32) Resource->ExtendedIrq.Interrupts[i]);
1118     }
1119
1120     AcpiDmIndent (Level);
1121     AcpiOsPrintf ("}\n");
1122 }
1123
1124
1125 /*******************************************************************************
1126  *
1127  * FUNCTION:    AcpiDmVendorCommon
1128  *
1129  * PARAMETERS:  Name                - Descriptor name suffix
1130  *              ByteData            - Pointer to the vendor byte data
1131  *              Length              - Length of the byte data
1132  *              Level               - Current source code indentation level
1133  *
1134  * RETURN:      None
1135  *
1136  * DESCRIPTION: Decode a Vendor descriptor, both Large and Small
1137  *
1138  ******************************************************************************/
1139
1140 void
1141 AcpiDmVendorCommon (
1142     const char              *Name,
1143     UINT8                   *ByteData,
1144     UINT32                  Length,
1145     UINT32                  Level)
1146 {
1147
1148     /* Dump macro name */
1149
1150     AcpiDmIndent (Level);
1151     AcpiOsPrintf ("Vendor%s (", Name);
1152
1153     /* Insert a descriptor name */
1154
1155     AcpiDmDescriptorName ();
1156     AcpiOsPrintf (")      // Length = 0x%.2X\n", Length);
1157
1158     /* Dump the vendor bytes */
1159
1160     AcpiDmIndent (Level);
1161     AcpiOsPrintf ("{\n");
1162
1163     AcpiDmDisasmByteList (Level + 1, ByteData, Length);
1164
1165     AcpiDmIndent (Level);
1166     AcpiOsPrintf ("}\n");
1167 }
1168
1169
1170 /*******************************************************************************
1171  *
1172  * FUNCTION:    AcpiDmVendorLargeDescriptor
1173  *
1174  * PARAMETERS:  Info                - Extra resource info
1175  *              Resource            - Pointer to the resource descriptor
1176  *              Length              - Length of the descriptor in bytes
1177  *              Level               - Current source code indentation level
1178  *
1179  * RETURN:      None
1180  *
1181  * DESCRIPTION: Decode a Vendor Large descriptor
1182  *
1183  ******************************************************************************/
1184
1185 void
1186 AcpiDmVendorLargeDescriptor (
1187     ACPI_OP_WALK_INFO       *Info,
1188     AML_RESOURCE            *Resource,
1189     UINT32                  Length,
1190     UINT32                  Level)
1191 {
1192
1193     AcpiDmVendorCommon ("Long ",
1194         ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_LARGE_HEADER)),
1195         Length, Level);
1196 }
1197
1198 #endif