xref: /titanic_41/usr/src/uts/intel/io/acpica/resources/rsdump.c (revision 8d483882aa3390058094b043f3d62187b5d1de03)
1 /*******************************************************************************
2  *
3  * Module Name: rsdump - Functions to display the resource structures.
4  *              $Revision: 1.61 $
5  *
6  ******************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116 
117 
118 #define __RSDUMP_C__
119 
120 #include "acpi.h"
121 #include "acresrc.h"
122 
123 #define _COMPONENT          ACPI_RESOURCES
124         ACPI_MODULE_NAME    ("rsdump")
125 
126 
127 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
128 
129 /* Local prototypes */
130 
131 static void
132 AcpiRsOutString (
133     char                    *Title,
134     char                    *Value);
135 
136 static void
137 AcpiRsOutInteger8 (
138     char                    *Title,
139     UINT8                   Value);
140 
141 static void
142 AcpiRsOutInteger16 (
143     char                    *Title,
144     UINT16                  Value);
145 
146 static void
147 AcpiRsOutInteger32 (
148     char                    *Title,
149     UINT32                  Value);
150 
151 static void
152 AcpiRsOutInteger64 (
153     char                    *Title,
154     UINT64                  Value);
155 
156 static void
157 AcpiRsOutTitle (
158     char                    *Title);
159 
160 static void
161 AcpiRsDumpByteList (
162     UINT16                  Length,
163     UINT8                   *Data);
164 
165 static void
166 AcpiRsDumpDwordList (
167     UINT8                   Length,
168     UINT32                  *Data);
169 
170 static void
171 AcpiRsDumpShortByteList (
172     UINT8                  Length,
173     UINT8                  *Data);
174 
175 static void
176 AcpiRsDumpResourceSource (
177     ACPI_RESOURCE_SOURCE    *ResourceSource);
178 
179 static void
180 AcpiRsDumpAddressCommon (
181     ACPI_RESOURCE_DATA      *Resource);
182 
183 static void
184 AcpiRsDumpDescriptor (
185     void                    *Resource,
186     ACPI_RSDUMP_INFO *Table);
187 
188 
189 #define ACPI_RSD_OFFSET(f)          (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f)
190 #define ACPI_PRT_OFFSET(f)          (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f)
191 #define ACPI_RSD_TABLE_SIZE(name)   (sizeof(name) / sizeof (ACPI_RSDUMP_INFO))
192 
193 
194 /*******************************************************************************
195  *
196  * Resource Descriptor info tables
197  *
198  * Note: The first table entry must be a Title or Literal and must contain
199  * the table length (number of table entries)
200  *
201  ******************************************************************************/
202 
203 ACPI_RSDUMP_INFO        AcpiRsDumpIrq[6] =
204 {
205     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq),                "IRQ",                      NULL},
206     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering),                   "Triggering",               AcpiGbl_HeDecode},
207     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity),                     "Polarity",                 AcpiGbl_LlDecode},
208     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable),                     "Sharing",                  AcpiGbl_ShrDecode},
209     {ACPI_RSD_UINT8 ,   ACPI_RSD_OFFSET (Irq.InterruptCount),               "Interrupt Count",          NULL},
210     {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]),                "Interrupt List",           NULL}
211 };
212 
213 ACPI_RSDUMP_INFO        AcpiRsDumpDma[6] =
214 {
215     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma),                "DMA",                      NULL},
216     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type),                         "Speed",                    AcpiGbl_TypDecode},
217     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster),                    "Mastering",                AcpiGbl_BmDecode},
218     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer),                     "Transfer Type",            AcpiGbl_SizDecode},
219     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (Dma.ChannelCount),                 "Channel Count",            NULL},
220     {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]),                  "Channel List",             NULL}
221 };
222 
223 ACPI_RSDUMP_INFO        AcpiRsDumpStartDpf[3] =
224 {
225     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf),           "Start-Dependent-Functions",NULL},
226     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority),   "Compatibility Priority",   AcpiGbl_ConfigDecode},
227     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness),   "Performance/Robustness",   AcpiGbl_ConfigDecode}
228 };
229 
230 ACPI_RSDUMP_INFO        AcpiRsDumpEndDpf[1] =
231 {
232     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf),             "End-Dependent-Functions",  NULL}
233 };
234 
235 ACPI_RSDUMP_INFO        AcpiRsDumpIo[6] =
236 {
237     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo),                 "I/O",                      NULL},
238     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode),                      "Address Decoding",         AcpiGbl_IoDecode},
239     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Io.Minimum),                       "Address Minimum",          NULL},
240     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Io.Maximum),                       "Address Maximum",          NULL},
241     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (Io.Alignment),                     "Alignment",                NULL},
242     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (Io.AddressLength),                 "Address Length",           NULL}
243 };
244 
245 ACPI_RSDUMP_INFO        AcpiRsDumpFixedIo[3] =
246 {
247     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo),            "Fixed I/O",                NULL},
248     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (FixedIo.Address),                  "Address",                  NULL},
249     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (FixedIo.AddressLength),            "Address Length",           NULL}
250 };
251 
252 ACPI_RSDUMP_INFO        AcpiRsDumpVendor[3] =
253 {
254     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor),             "Vendor Specific",          NULL},
255     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Vendor.ByteLength),                "Length",                   NULL},
256     {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]),               "Vendor Data",              NULL}
257 };
258 
259 ACPI_RSDUMP_INFO        AcpiRsDumpEndTag[1] =
260 {
261     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag),             "EndTag",                   NULL}
262 };
263 
264 ACPI_RSDUMP_INFO        AcpiRsDumpMemory24[6] =
265 {
266     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24),           "24-Bit Memory Range",      NULL},
267     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect),            "Write Protect",            AcpiGbl_RwDecode},
268     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.Minimum),                 "Address Minimum",          NULL},
269     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.Maximum),                 "Address Maximum",          NULL},
270     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.Alignment),               "Alignment",                NULL},
271     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.AddressLength),           "Address Length",           NULL}
272 };
273 
274 ACPI_RSDUMP_INFO        AcpiRsDumpMemory32[6] =
275 {
276     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32),           "32-Bit Memory Range",      NULL},
277     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect),            "Write Protect",            AcpiGbl_RwDecode},
278     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.Minimum),                 "Address Minimum",          NULL},
279     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.Maximum),                 "Address Maximum",          NULL},
280     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.Alignment),               "Alignment",                NULL},
281     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.AddressLength),           "Address Length",           NULL}
282 };
283 
284 ACPI_RSDUMP_INFO        AcpiRsDumpFixedMemory32[4] =
285 {
286     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32),      "32-Bit Fixed Memory Range",NULL},
287     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect),       "Write Protect",            AcpiGbl_RwDecode},
288     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (FixedMemory32.Address),            "Address",                  NULL},
289     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (FixedMemory32.AddressLength),      "Address Length",           NULL}
290 };
291 
292 ACPI_RSDUMP_INFO        AcpiRsDumpAddress16[8] =
293 {
294     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16),          "16-Bit WORD Address Space",NULL},
295     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
296     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.Granularity),            "Granularity",              NULL},
297     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.Minimum),                "Address Minimum",          NULL},
298     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.Maximum),                "Address Maximum",          NULL},
299     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.TranslationOffset),      "Translation Offset",       NULL},
300     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.AddressLength),          "Address Length",           NULL},
301     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (Address16.ResourceSource),         NULL,                       NULL}
302 };
303 
304 ACPI_RSDUMP_INFO        AcpiRsDumpAddress32[8] =
305 {
306     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32),         "32-Bit DWORD Address Space", NULL},
307     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
308     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.Granularity),            "Granularity",              NULL},
309     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.Minimum),                "Address Minimum",          NULL},
310     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.Maximum),                "Address Maximum",          NULL},
311     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.TranslationOffset),      "Translation Offset",       NULL},
312     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.AddressLength),          "Address Length",           NULL},
313     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (Address32.ResourceSource),         NULL,                       NULL}
314 };
315 
316 ACPI_RSDUMP_INFO        AcpiRsDumpAddress64[8] =
317 {
318     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64),          "64-Bit QWORD Address Space", NULL},
319     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
320     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.Granularity),            "Granularity",              NULL},
321     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.Minimum),                "Address Minimum",          NULL},
322     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.Maximum),                "Address Maximum",          NULL},
323     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.TranslationOffset),      "Translation Offset",       NULL},
324     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.AddressLength),          "Address Length",           NULL},
325     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (Address64.ResourceSource),         NULL,                       NULL}
326 };
327 
328 ACPI_RSDUMP_INFO        AcpiRsDumpExtAddress64[8] =
329 {
330     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64),       "64-Bit Extended Address Space", NULL},
331     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
332     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.Granularity),         "Granularity",              NULL},
333     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.Minimum),             "Address Minimum",          NULL},
334     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.Maximum),             "Address Maximum",          NULL},
335     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset),   "Translation Offset",       NULL},
336     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.AddressLength),       "Address Length",           NULL},
337     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific),        "Type-Specific Attribute",  NULL}
338 };
339 
340 ACPI_RSDUMP_INFO        AcpiRsDumpExtIrq[8] =
341 {
342     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq),             "Extended IRQ",             NULL},
343     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer),     "Type",                     AcpiGbl_ConsumeDecode},
344     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering),           "Triggering",               AcpiGbl_HeDecode},
345     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity),             "Polarity",                 AcpiGbl_LlDecode},
346     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable),             "Sharing",                  AcpiGbl_ShrDecode},
347     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource),       NULL,                       NULL},
348     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount),       "Interrupt Count",          NULL},
349     {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]),        "Interrupt List",           NULL}
350 };
351 
352 ACPI_RSDUMP_INFO        AcpiRsDumpGenericReg[6] =
353 {
354     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg),         "Generic Register",         NULL},
355     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.SpaceId),               "Space ID",                 NULL},
356     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.BitWidth),              "Bit Width",                NULL},
357     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.BitOffset),             "Bit Offset",               NULL},
358     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.AccessSize),            "Access Size",              NULL},
359     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (GenericReg.Address),               "Address",                  NULL}
360 };
361 
362 
363 /*
364  * Tables used for common address descriptor flag fields
365  */
366 static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] =
367 {
368     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags),       NULL,                       NULL},
369     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer),         "Consumer/Producer",        AcpiGbl_ConsumeDecode},
370     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode),                   "Address Decode",           AcpiGbl_DecDecode},
371     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed),          "Min Relocatability",       AcpiGbl_MinDecode},
372     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed),          "Max Relocatability",       AcpiGbl_MaxDecode}
373 };
374 
375 static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] =
376 {
377     {ACPI_RSD_LITERAL,  ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags),        "Resource Type",            (void *) "Memory Range"},
378     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect),    "Write Protect",            AcpiGbl_RwDecode},
379     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching),         "Caching",                  AcpiGbl_MemDecode},
380     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType),       "Range Type",               AcpiGbl_MtpDecode},
381     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation),     "Translation",              AcpiGbl_TtpDecode}
382 };
383 
384 static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] =
385 {
386     {ACPI_RSD_LITERAL,  ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags),            "Resource Type",            (void *) "I/O Range"},
387     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType),        "Range Type",               AcpiGbl_RngDecode},
388     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation),      "Translation",              AcpiGbl_TtpDecode},
389     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType),  "Translation Type",         AcpiGbl_TrsDecode}
390 };
391 
392 
393 /*
394  * Table used to dump _PRT contents
395  */
396 static ACPI_RSDUMP_INFO   AcpiRsDumpPrt[5] =
397 {
398     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt),                NULL,                       NULL},
399     {ACPI_RSD_UINT64,   ACPI_PRT_OFFSET (Address),                          "Address",                  NULL},
400     {ACPI_RSD_UINT32,   ACPI_PRT_OFFSET (Pin),                              "Pin",                      NULL},
401     {ACPI_RSD_STRING,   ACPI_PRT_OFFSET (Source[0]),                        "Source",                   NULL},
402     {ACPI_RSD_UINT32,   ACPI_PRT_OFFSET (SourceIndex),                      "Source Index",             NULL}
403 };
404 
405 
406 /*******************************************************************************
407  *
408  * FUNCTION:    AcpiRsDumpDescriptor
409  *
410  * PARAMETERS:  Resource
411  *
412  * RETURN:      None
413  *
414  * DESCRIPTION:
415  *
416  ******************************************************************************/
417 
418 static void
419 AcpiRsDumpDescriptor (
420     void                    *Resource,
421     ACPI_RSDUMP_INFO        *Table)
422 {
423     UINT8                   *Target = NULL;
424     UINT8                   *PreviousTarget;
425     char                    *Name;
426     UINT8                    Count;
427 
428 
429     /* First table entry must contain the table length (# of table entries) */
430 
431     Count = Table->Offset;
432 
433     while (Count)
434     {
435         PreviousTarget = Target;
436         Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset);
437         Name = Table->Name;
438 
439         switch (Table->Opcode)
440         {
441         case ACPI_RSD_TITLE:
442             /*
443              * Optional resource title
444              */
445             if (Table->Name)
446             {
447                 AcpiOsPrintf ("%s Resource\n", Name);
448             }
449             break;
450 
451         /* Strings */
452 
453         case ACPI_RSD_LITERAL:
454             AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer));
455             break;
456 
457         case ACPI_RSD_STRING:
458             AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target));
459             break;
460 
461         /* Data items, 8/16/32/64 bit */
462 
463         case ACPI_RSD_UINT8:
464             AcpiRsOutInteger8 (Name, ACPI_GET8 (Target));
465             break;
466 
467         case ACPI_RSD_UINT16:
468             AcpiRsOutInteger16 (Name, ACPI_GET16 (Target));
469             break;
470 
471         case ACPI_RSD_UINT32:
472             AcpiRsOutInteger32 (Name, ACPI_GET32 (Target));
473             break;
474 
475         case ACPI_RSD_UINT64:
476             AcpiRsOutInteger64 (Name, ACPI_GET64 (Target));
477             break;
478 
479         /* Flags: 1-bit and 2-bit flags supported */
480 
481         case ACPI_RSD_1BITFLAG:
482             AcpiRsOutString (Name, ACPI_CAST_PTR (char,
483                 Table->Pointer [*Target & 0x01]));
484             break;
485 
486         case ACPI_RSD_2BITFLAG:
487             AcpiRsOutString (Name, ACPI_CAST_PTR (char,
488                 Table->Pointer [*Target & 0x03]));
489             break;
490 
491         case ACPI_RSD_SHORTLIST:
492             /*
493              * Short byte list (single line output) for DMA and IRQ resources
494              * Note: The list length is obtained from the previous table entry
495              */
496             if (PreviousTarget)
497             {
498                 AcpiRsOutTitle (Name);
499                 AcpiRsDumpShortByteList (*PreviousTarget, Target);
500             }
501             break;
502 
503         case ACPI_RSD_LONGLIST:
504             /*
505              * Long byte list for Vendor resource data
506              * Note: The list length is obtained from the previous table entry
507              */
508             if (PreviousTarget)
509             {
510                 AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target);
511             }
512             break;
513 
514         case ACPI_RSD_DWORDLIST:
515             /*
516              * Dword list for Extended Interrupt resources
517              * Note: The list length is obtained from the previous table entry
518              */
519             if (PreviousTarget)
520             {
521                 AcpiRsDumpDwordList (*PreviousTarget,
522                     ACPI_CAST_PTR (UINT32, Target));
523             }
524             break;
525 
526         case ACPI_RSD_ADDRESS:
527             /*
528              * Common flags for all Address resources
529              */
530             AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target));
531             break;
532 
533         case ACPI_RSD_SOURCE:
534             /*
535              * Optional ResourceSource for Address resources
536              */
537             AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target));
538             break;
539 
540         default:
541             AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
542                 Table->Opcode);
543             return;
544         }
545 
546         Table++;
547         Count--;
548     }
549 }
550 
551 
552 /*******************************************************************************
553  *
554  * FUNCTION:    AcpiRsDumpResourceSource
555  *
556  * PARAMETERS:  ResourceSource      - Pointer to a Resource Source struct
557  *
558  * RETURN:      None
559  *
560  * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
561  *              corresponding ResourceSourceIndex.
562  *
563  ******************************************************************************/
564 
565 static void
566 AcpiRsDumpResourceSource (
567     ACPI_RESOURCE_SOURCE    *ResourceSource)
568 {
569     ACPI_FUNCTION_ENTRY ();
570 
571 
572     if (ResourceSource->Index == 0xFF)
573     {
574         return;
575     }
576 
577     AcpiRsOutInteger8 ("Resource Source Index",
578         ResourceSource->Index);
579 
580     AcpiRsOutString ("Resource Source",
581         ResourceSource->StringPtr ?
582             ResourceSource->StringPtr : "[Not Specified]");
583 }
584 
585 
586 /*******************************************************************************
587  *
588  * FUNCTION:    AcpiRsDumpAddressCommon
589  *
590  * PARAMETERS:  Resource        - Pointer to an internal resource descriptor
591  *
592  * RETURN:      None
593  *
594  * DESCRIPTION: Dump the fields that are common to all Address resource
595  *              descriptors
596  *
597  ******************************************************************************/
598 
599 static void
600 AcpiRsDumpAddressCommon (
601     ACPI_RESOURCE_DATA      *Resource)
602 {
603     ACPI_FUNCTION_ENTRY ();
604 
605 
606    /* Decode the type-specific flags */
607 
608     switch (Resource->Address.ResourceType)
609     {
610     case ACPI_MEMORY_RANGE:
611 
612         AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
613         break;
614 
615     case ACPI_IO_RANGE:
616 
617         AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
618         break;
619 
620     case ACPI_BUS_NUMBER_RANGE:
621 
622         AcpiRsOutString ("Resource Type", "Bus Number Range");
623         break;
624 
625     default:
626 
627         AcpiRsOutInteger8 ("Resource Type",
628             (UINT8) Resource->Address.ResourceType);
629         break;
630     }
631 
632     /* Decode the general flags */
633 
634     AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
635 }
636 
637 
638 /*******************************************************************************
639  *
640  * FUNCTION:    AcpiRsDumpResourceList
641  *
642  * PARAMETERS:  ResourceList        - Pointer to a resource descriptor list
643  *
644  * RETURN:      None
645  *
646  * DESCRIPTION: Dispatches the structure to the correct dump routine.
647  *
648  ******************************************************************************/
649 
650 void
651 AcpiRsDumpResourceList (
652     ACPI_RESOURCE           *ResourceList)
653 {
654     UINT32                  Count = 0;
655     UINT32                  Type;
656 
657 
658     ACPI_FUNCTION_ENTRY ();
659 
660 
661     if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
662     {
663         return;
664     }
665 
666     /* Walk list and dump all resource descriptors (END_TAG terminates) */
667 
668     do
669     {
670         AcpiOsPrintf ("\n[%02X] ", Count);
671         Count++;
672 
673         /* Validate Type before dispatch */
674 
675         Type = ResourceList->Type;
676         if (Type > ACPI_RESOURCE_TYPE_MAX)
677         {
678             AcpiOsPrintf (
679                 "Invalid descriptor type (%X) in resource list\n",
680                 ResourceList->Type);
681             return;
682         }
683 
684         /* Dump the resource descriptor */
685 
686         AcpiRsDumpDescriptor (&ResourceList->Data,
687             AcpiGbl_DumpResourceDispatch[Type]);
688 
689         /* Point to the next resource structure */
690 
691         ResourceList = ACPI_ADD_PTR (ACPI_RESOURCE, ResourceList,
692                             ResourceList->Length);
693 
694         /* Exit when END_TAG descriptor is reached */
695 
696     } while (Type != ACPI_RESOURCE_TYPE_END_TAG);
697 }
698 
699 
700 /*******************************************************************************
701  *
702  * FUNCTION:    AcpiRsDumpIrqList
703  *
704  * PARAMETERS:  RouteTable      - Pointer to the routing table to dump.
705  *
706  * RETURN:      None
707  *
708  * DESCRIPTION: Print IRQ routing table
709  *
710  ******************************************************************************/
711 
712 void
713 AcpiRsDumpIrqList (
714     UINT8                   *RouteTable)
715 {
716     ACPI_PCI_ROUTING_TABLE  *PrtElement;
717     UINT8                   Count;
718 
719 
720     ACPI_FUNCTION_ENTRY ();
721 
722 
723     if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
724     {
725         return;
726     }
727 
728     PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
729 
730     /* Dump all table elements, Exit on zero length element */
731 
732     for (Count = 0; PrtElement->Length; Count++)
733     {
734         AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
735         AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
736 
737         PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE,
738                         PrtElement, PrtElement->Length);
739     }
740 }
741 
742 
743 /*******************************************************************************
744  *
745  * FUNCTION:    AcpiRsOut*
746  *
747  * PARAMETERS:  Title       - Name of the resource field
748  *              Value       - Value of the resource field
749  *
750  * RETURN:      None
751  *
752  * DESCRIPTION: Miscellaneous helper functions to consistently format the
753  *              output of the resource dump routines
754  *
755  ******************************************************************************/
756 
757 static void
758 AcpiRsOutString (
759     char                    *Title,
760     char                    *Value)
761 {
762     AcpiOsPrintf ("%27s : %s", Title, Value);
763     if (!*Value)
764     {
765         AcpiOsPrintf ("[NULL NAMESTRING]");
766     }
767     AcpiOsPrintf ("\n");
768 }
769 
770 static void
771 AcpiRsOutInteger8 (
772     char                    *Title,
773     UINT8                   Value)
774 {
775     AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
776 }
777 
778 static void
779 AcpiRsOutInteger16 (
780     char                    *Title,
781     UINT16                  Value)
782 {
783     AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
784 }
785 
786 static void
787 AcpiRsOutInteger32 (
788     char                    *Title,
789     UINT32                  Value)
790 {
791     AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
792 }
793 
794 static void
795 AcpiRsOutInteger64 (
796     char                    *Title,
797     UINT64                  Value)
798 {
799     AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
800         ACPI_FORMAT_UINT64 (Value));
801 }
802 
803 static void
804 AcpiRsOutTitle (
805     char                    *Title)
806 {
807     AcpiOsPrintf ("%27s : ", Title);
808 }
809 
810 
811 /*******************************************************************************
812  *
813  * FUNCTION:    AcpiRsDump*List
814  *
815  * PARAMETERS:  Length      - Number of elements in the list
816  *              Data        - Start of the list
817  *
818  * RETURN:      None
819  *
820  * DESCRIPTION: Miscellaneous functions to dump lists of raw data
821  *
822  ******************************************************************************/
823 
824 static void
825 AcpiRsDumpByteList (
826     UINT16                  Length,
827     UINT8                   *Data)
828 {
829     UINT8                   i;
830 
831 
832     for (i = 0; i < Length; i++)
833     {
834         AcpiOsPrintf ("%25s%2.2X : %2.2X\n",
835             "Byte", i, Data[i]);
836     }
837 }
838 
839 static void
840 AcpiRsDumpShortByteList (
841     UINT8                  Length,
842     UINT8                  *Data)
843 {
844     UINT8                   i;
845 
846 
847     for (i = 0; i < Length; i++)
848     {
849         AcpiOsPrintf ("%X ", Data[i]);
850     }
851     AcpiOsPrintf ("\n");
852 }
853 
854 static void
855 AcpiRsDumpDwordList (
856     UINT8                   Length,
857     UINT32                  *Data)
858 {
859     UINT8                   i;
860 
861 
862     for (i = 0; i < Length; i++)
863     {
864         AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
865             "Dword", i, Data[i]);
866     }
867 }
868 
869 #endif
870 
871