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