]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/rsdump.c
This commit was generated by cvs2svn to compensate for changes in r167802,
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / rsdump.c
1 /*******************************************************************************
2  *
3  * Module Name: rsdump - Functions to display the resource structures.
4  *              $Revision: 1.54 $
5  *
6  ******************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2005, 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 <contrib/dev/acpica/acpi.h>
121 #include <contrib/dev/acpica/acresrc.h>
122 #include <contrib/dev/acpica/acdisasm.h>
123
124 #define _COMPONENT          ACPI_RESOURCES
125         ACPI_MODULE_NAME    ("rsdump")
126
127
128 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
129
130 /* Local prototypes */
131
132 static void
133 AcpiRsOutString (
134     char                    *Title,
135     char                    *Value);
136
137 static void
138 AcpiRsOutInteger8 (
139     char                    *Title,
140     UINT8                   Value);
141
142 static void
143 AcpiRsOutInteger16 (
144     char                    *Title,
145     UINT16                  Value);
146
147 static void
148 AcpiRsOutInteger32 (
149     char                    *Title,
150     UINT32                  Value);
151
152 static void
153 AcpiRsOutInteger64 (
154     char                    *Title,
155     UINT64                  Value);
156
157 static void
158 AcpiRsOutTitle (
159     char                    *Title);
160
161 static void
162 AcpiRsDumpByteList (
163     UINT16                  Length,
164     UINT8                   *Data);
165
166 static void
167 AcpiRsDumpDwordList (
168     UINT8                   Length,
169     UINT32                  *Data);
170
171 static void
172 AcpiRsDumpShortByteList (
173     UINT8                  Length,
174     UINT8                  *Data);
175
176 static void
177 AcpiRsDumpResourceSource (
178     ACPI_RESOURCE_SOURCE    *ResourceSource);
179
180 static void
181 AcpiRsDumpAddressCommon (
182     ACPI_RESOURCE_DATA      *Resource);
183
184 static void
185 AcpiRsDumpDescriptor (
186     void                    *Resource,
187     ACPI_RSDUMP_INFO *Table);
188
189
190 #define ACPI_RSD_OFFSET(f)          (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f)
191 #define ACPI_PRT_OFFSET(f)          (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f)
192 #define ACPI_RSD_TABLE_SIZE(name)   (sizeof(name) / sizeof (ACPI_RSDUMP_INFO))
193
194
195 /*******************************************************************************
196  *
197  * Resource Descriptor info tables
198  *
199  * Note: The first table entry must be a Title or Literal and must contain
200  * the table length (number of table entries)
201  *
202  ******************************************************************************/
203
204 ACPI_RSDUMP_INFO        AcpiRsDumpIrq[6] =
205 {
206     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq),                "IRQ",                      NULL},
207     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering),                   "Triggering",               AcpiGbl_HEDecode},
208     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity),                     "Polarity",                 AcpiGbl_LLDecode},
209     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable),                     "Sharing",                  AcpiGbl_SHRDecode},
210     {ACPI_RSD_UINT8 ,   ACPI_RSD_OFFSET (Irq.InterruptCount),               "Interrupt Count",          NULL},
211     {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]),                "Interrupt List",           NULL}
212 };
213
214 ACPI_RSDUMP_INFO        AcpiRsDumpDma[6] =
215 {
216     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma),                "DMA",                      NULL},
217     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type),                         "Speed",                    AcpiGbl_TYPDecode},
218     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster),                    "Mastering",                AcpiGbl_BMDecode},
219     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer),                     "Transfer Type",            AcpiGbl_SIZDecode},
220     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (Dma.ChannelCount),                 "Channel Count",            NULL},
221     {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]),                  "Channel List",             NULL}
222 };
223
224 ACPI_RSDUMP_INFO        AcpiRsDumpStartDpf[3] =
225 {
226     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf),           "Start-Dependent-Functions",NULL},
227     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority),   "Compatibility Priority",   AcpiGbl_ConfigDecode},
228     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness),   "Performance/Robustness",   AcpiGbl_ConfigDecode}
229 };
230
231 ACPI_RSDUMP_INFO        AcpiRsDumpEndDpf[1] =
232 {
233     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf),             "End-Dependent-Functions",  NULL}
234 };
235
236 ACPI_RSDUMP_INFO        AcpiRsDumpIo[6] =
237 {
238     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo),                 "I/O",                      NULL},
239     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode),                      "Address Decoding",         AcpiGbl_IoDecode},
240     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Io.Minimum),                       "Address Minimum",          NULL},
241     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Io.Maximum),                       "Address Maximum",          NULL},
242     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (Io.Alignment),                     "Alignment",                NULL},
243     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (Io.AddressLength),                 "Address Length",           NULL}
244 };
245
246 ACPI_RSDUMP_INFO        AcpiRsDumpFixedIo[3] =
247 {
248     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo),            "Fixed I/O",                NULL},
249     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (FixedIo.Address),                  "Address",                  NULL},
250     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (FixedIo.AddressLength),            "Address Length",           NULL}
251 };
252
253 ACPI_RSDUMP_INFO        AcpiRsDumpVendor[3] =
254 {
255     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor),             "Vendor Specific",          NULL},
256     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Vendor.ByteLength),                "Length",                   NULL},
257     {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]),               "Vendor Data",              NULL}
258 };
259
260 ACPI_RSDUMP_INFO        AcpiRsDumpEndTag[1] =
261 {
262     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag),             "EndTag",                   NULL}
263 };
264
265 ACPI_RSDUMP_INFO        AcpiRsDumpMemory24[6] =
266 {
267     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24),           "24-Bit Memory Range",      NULL},
268     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect),            "Write Protect",            AcpiGbl_RWDecode},
269     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.Minimum),                 "Address Minimum",          NULL},
270     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.Maximum),                 "Address Maximum",          NULL},
271     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.Alignment),               "Alignment",                NULL},
272     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.AddressLength),           "Address Length",           NULL}
273 };
274
275 ACPI_RSDUMP_INFO        AcpiRsDumpMemory32[6] =
276 {
277     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32),           "32-Bit Memory Range",      NULL},
278     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect),            "Write Protect",            AcpiGbl_RWDecode},
279     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.Minimum),                 "Address Minimum",          NULL},
280     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.Maximum),                 "Address Maximum",          NULL},
281     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.Alignment),               "Alignment",                NULL},
282     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.AddressLength),           "Address Length",           NULL}
283 };
284
285 ACPI_RSDUMP_INFO        AcpiRsDumpFixedMemory32[4] =
286 {
287     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32),      "32-Bit Fixed Memory Range",NULL},
288     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect),       "Write Protect",            AcpiGbl_RWDecode},
289     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (FixedMemory32.Address),            "Address",                  NULL},
290     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (FixedMemory32.AddressLength),      "Address Length",           NULL}
291 };
292
293 ACPI_RSDUMP_INFO        AcpiRsDumpAddress16[8] =
294 {
295     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16),          "16-Bit WORD Address Space",NULL},
296     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
297     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.Granularity),            "Granularity",              NULL},
298     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.Minimum),                "Address Minimum",          NULL},
299     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.Maximum),                "Address Maximum",          NULL},
300     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.TranslationOffset),      "Translation Offset",       NULL},
301     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.AddressLength),          "Address Length",           NULL},
302     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (Address16.ResourceSource),         NULL,                       NULL}
303 };
304
305 ACPI_RSDUMP_INFO        AcpiRsDumpAddress32[8] =
306 {
307     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32),         "32-Bit DWORD Address Space", NULL},
308     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
309     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.Granularity),            "Granularity",              NULL},
310     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.Minimum),                "Address Minimum",          NULL},
311     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.Maximum),                "Address Maximum",          NULL},
312     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.TranslationOffset),      "Translation Offset",       NULL},
313     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.AddressLength),          "Address Length",           NULL},
314     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (Address32.ResourceSource),         NULL,                       NULL}
315 };
316
317 ACPI_RSDUMP_INFO        AcpiRsDumpAddress64[8] =
318 {
319     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64),          "64-Bit QWORD Address Space", NULL},
320     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
321     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.Granularity),            "Granularity",              NULL},
322     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.Minimum),                "Address Minimum",          NULL},
323     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.Maximum),                "Address Maximum",          NULL},
324     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.TranslationOffset),      "Translation Offset",       NULL},
325     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.AddressLength),          "Address Length",           NULL},
326     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (Address64.ResourceSource),         NULL,                       NULL}
327 };
328
329 ACPI_RSDUMP_INFO        AcpiRsDumpExtAddress64[8] =
330 {
331     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64),       "64-Bit Extended Address Space", NULL},
332     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
333     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.Granularity),         "Granularity",              NULL},
334     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.Minimum),             "Address Minimum",          NULL},
335     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.Maximum),             "Address Maximum",          NULL},
336     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset),   "Translation Offset",       NULL},
337     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.AddressLength),       "Address Length",           NULL},
338     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific),        "Type-Specific Attribute",  NULL}
339 };
340
341 ACPI_RSDUMP_INFO        AcpiRsDumpExtIrq[8] =
342 {
343     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq),             "Extended IRQ",             NULL},
344     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer),     "Type",                     AcpiGbl_ConsumeDecode},
345     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering),           "Triggering",               AcpiGbl_HEDecode},
346     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity),             "Polarity",                 AcpiGbl_LLDecode},
347     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable),             "Sharing",                  AcpiGbl_SHRDecode},
348     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource),       NULL,                       NULL},
349     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount),       "Interrupt Count",          NULL},
350     {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]),        "Interrupt List",           NULL}
351 };
352
353 ACPI_RSDUMP_INFO        AcpiRsDumpGenericReg[6] =
354 {
355     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg),         "Generic Register",         NULL},
356     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.SpaceId),               "Space ID",                 NULL},
357     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.BitWidth),              "Bit Width",                NULL},
358     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.BitOffset),             "Bit Offset",               NULL},
359     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.AccessSize),            "Access Size",              NULL},
360     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (GenericReg.Address),               "Address",                  NULL}
361 };
362
363
364 /*
365  * Tables used for common address descriptor flag fields
366  */
367 static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] =
368 {
369     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags),       NULL,                       NULL},
370     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer),         "Consumer/Producer",        AcpiGbl_ConsumeDecode},
371     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode),                   "Address Decode",           AcpiGbl_DECDecode},
372     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed),          "Min Relocatability",       AcpiGbl_MinDecode},
373     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed),          "Max Relocatability",       AcpiGbl_MaxDecode}
374 };
375
376 static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] =
377 {
378     {ACPI_RSD_LITERAL,  ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags),        "Resource Type",            "Memory Range"},
379     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect),    "Write Protect",            AcpiGbl_RWDecode},
380     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching),         "Caching",                  AcpiGbl_MEMDecode},
381     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType),       "Range Type",               AcpiGbl_MTPDecode},
382     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation),     "Translation",              AcpiGbl_TTPDecode}
383 };
384
385 static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] =
386 {
387     {ACPI_RSD_LITERAL,  ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags),            "Resource Type",            "I/O Range"},
388     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType),        "Range Type",               AcpiGbl_RNGDecode},
389     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation),      "Translation",              AcpiGbl_TTPDecode},
390     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType),  "Translation Type",         AcpiGbl_TRSDecode}
391 };
392
393
394 /*
395  * Table used to dump _PRT contents
396  */
397 static ACPI_RSDUMP_INFO   AcpiRsDumpPrt[5] =
398 {
399     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt),                NULL,                       NULL},
400     {ACPI_RSD_UINT64,   ACPI_PRT_OFFSET (Address),                          "Address",                  NULL},
401     {ACPI_RSD_UINT32,   ACPI_PRT_OFFSET (Pin),                              "Pin",                      NULL},
402     {ACPI_RSD_STRING,   ACPI_PRT_OFFSET (Source[0]),                        "Source",                   NULL},
403     {ACPI_RSD_UINT32,   ACPI_PRT_OFFSET (SourceIndex),                      "Source Index",             NULL}
404 };
405
406
407 /*******************************************************************************
408  *
409  * FUNCTION:    AcpiRsDumpDescriptor
410  *
411  * PARAMETERS:  Resource
412  *
413  * RETURN:      None
414  *
415  * DESCRIPTION:
416  *
417  ******************************************************************************/
418
419 static void
420 AcpiRsDumpDescriptor (
421     void                    *Resource,
422     ACPI_RSDUMP_INFO        *Table)
423 {
424     void                    *Target = NULL;
425     void                    *PreviousTarget;
426     char                    *Name;
427     UINT8                    Count;
428
429
430     /* First table entry must contain the table length (# of table entries) */
431
432     Count = Table->Offset;
433
434     while (Count)
435     {
436         PreviousTarget = Target;
437         Target = ((UINT8 *) Resource) + Table->Offset;
438         Name = Table->Name;
439
440         switch (Table->Opcode)
441         {
442         case ACPI_RSD_TITLE:
443             /*
444              * Optional resource title
445              */
446             if (Table->Name)
447             {
448                 AcpiOsPrintf ("%s Resource\n", Name);
449             }
450             break;
451
452         /* Strings */
453
454         case ACPI_RSD_LITERAL:
455             AcpiRsOutString (Name, (char *) (uintptr_t) Table->Pointer);
456             break;
457
458         case ACPI_RSD_STRING:
459             AcpiRsOutString (Name, (char *) (uintptr_t) Target);
460             break;
461
462         /* Data items, 8/16/32/64 bit */
463
464         case ACPI_RSD_UINT8:
465             AcpiRsOutInteger8 (Name, *(UINT8 *) Target);
466             break;
467
468         case ACPI_RSD_UINT16:
469             AcpiRsOutInteger16 (Name, *(UINT16 *) Target);
470             break;
471
472         case ACPI_RSD_UINT32:
473             AcpiRsOutInteger32 (Name, *(UINT32 *) Target);
474             break;
475
476         case ACPI_RSD_UINT64:
477             AcpiRsOutInteger64 (Name, *(UINT64 *) Target);
478             break;
479
480         /* Flags: 1-bit and 2-bit flags supported */
481
482         case ACPI_RSD_1BITFLAG:
483             AcpiRsOutString (Name, (char *) (uintptr_t)
484                 ((const char **) (uintptr_t) Table->Pointer)[(*(UINT8 *) Target) & 0x01]);
485             break;
486
487         case ACPI_RSD_2BITFLAG:
488             AcpiRsOutString (Name, (char *) (uintptr_t)
489                 ((const char **) (uintptr_t) Table->Pointer)[(*(UINT8 *) Target) & 0x03]);
490             break;
491
492         case ACPI_RSD_SHORTLIST:
493             /*
494              * Short byte list (single line output) for DMA and IRQ resources
495              * Note: The list length is obtained from the previous table entry
496              */
497             if (PreviousTarget)
498             {
499                 AcpiRsOutTitle (Name);
500                 AcpiRsDumpShortByteList (*((UINT8 *) PreviousTarget),
501                     (UINT8 *) Target);
502             }
503             break;
504
505         case ACPI_RSD_LONGLIST:
506             /*
507              * Long byte list for Vendor resource data
508              * Note: The list length is obtained from the previous table entry
509              */
510             if (PreviousTarget)
511             {
512                 AcpiRsDumpByteList (*((UINT16 *) PreviousTarget),
513                     (UINT8 *) Target);
514             }
515             break;
516
517         case ACPI_RSD_DWORDLIST:
518             /*
519              * Dword list for Extended Interrupt resources
520              * Note: The list length is obtained from the previous table entry
521              */
522             if (PreviousTarget)
523             {
524                 AcpiRsDumpDwordList (*((UINT8 *) PreviousTarget),
525                     (UINT32 *) Target);
526             }
527             break;
528
529         case ACPI_RSD_ADDRESS:
530             /*
531              * Common flags for all Address resources
532              */
533             AcpiRsDumpAddressCommon ((ACPI_RESOURCE_DATA *) Target);
534             break;
535
536         case ACPI_RSD_SOURCE:
537             /*
538              * Optional ResourceSource for Address resources
539              */
540             AcpiRsDumpResourceSource ((ACPI_RESOURCE_SOURCE *) Target);
541             break;
542
543         default:
544             AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
545                 Table->Opcode);
546             return;
547         }
548
549         Table++;
550         Count--;
551     }
552 }
553
554
555 /*******************************************************************************
556  *
557  * FUNCTION:    AcpiRsDumpResourceSource
558  *
559  * PARAMETERS:  ResourceSource      - Pointer to a Resource Source struct
560  *
561  * RETURN:      None
562  *
563  * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
564  *              corresponding ResourceSourceIndex.
565  *
566  ******************************************************************************/
567
568 static void
569 AcpiRsDumpResourceSource (
570     ACPI_RESOURCE_SOURCE    *ResourceSource)
571 {
572     ACPI_FUNCTION_ENTRY ();
573
574
575     if (ResourceSource->Index == 0xFF)
576     {
577         return;
578     }
579
580     AcpiRsOutInteger8 ("Resource Source Index",
581         ResourceSource->Index);
582
583     AcpiRsOutString ("Resource Source",
584         ResourceSource->StringPtr ?
585             ResourceSource->StringPtr : "[Not Specified]");
586 }
587
588
589 /*******************************************************************************
590  *
591  * FUNCTION:    AcpiRsDumpAddressCommon
592  *
593  * PARAMETERS:  Resource        - Pointer to an internal resource descriptor
594  *
595  * RETURN:      None
596  *
597  * DESCRIPTION: Dump the fields that are common to all Address resource
598  *              descriptors
599  *
600  ******************************************************************************/
601
602 static void
603 AcpiRsDumpAddressCommon (
604     ACPI_RESOURCE_DATA      *Resource)
605 {
606     ACPI_FUNCTION_ENTRY ();
607
608
609    /* Decode the type-specific flags */
610
611     switch (Resource->Address.ResourceType)
612     {
613     case ACPI_MEMORY_RANGE:
614
615         AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
616         break;
617
618     case ACPI_IO_RANGE:
619
620         AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
621         break;
622
623     case ACPI_BUS_NUMBER_RANGE:
624
625         AcpiRsOutString ("Resource Type", "Bus Number Range");
626         break;
627
628     default:
629
630         AcpiRsOutInteger8 ("Resource Type",
631             (UINT8) Resource->Address.ResourceType);
632         break;
633     }
634
635     /* Decode the general flags */
636
637     AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
638 }
639
640
641 /*******************************************************************************
642  *
643  * FUNCTION:    AcpiRsDumpResourceList
644  *
645  * PARAMETERS:  ResourceList        - Pointer to a resource descriptor list
646  *
647  * RETURN:      None
648  *
649  * DESCRIPTION: Dispatches the structure to the correct dump routine.
650  *
651  ******************************************************************************/
652
653 void
654 AcpiRsDumpResourceList (
655     ACPI_RESOURCE           *ResourceList)
656 {
657     UINT32                  Count = 0;
658     UINT32                  Type;
659
660
661     ACPI_FUNCTION_ENTRY ();
662
663
664     if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
665     {
666         return;
667     }
668
669     /* Walk list and dump all resource descriptors (END_TAG terminates) */
670
671     do
672     {
673         AcpiOsPrintf ("\n[%02X] ", Count);
674         Count++;
675
676         /* Validate Type before dispatch */
677
678         Type = ResourceList->Type;
679         if (Type > ACPI_RESOURCE_TYPE_MAX)
680         {
681             AcpiOsPrintf (
682                 "Invalid descriptor type (%X) in resource list\n",
683                 ResourceList->Type);
684             return;
685         }
686
687         /* Dump the resource descriptor */
688
689         AcpiRsDumpDescriptor (&ResourceList->Data,
690             AcpiGbl_DumpResourceDispatch[Type]);
691
692         /* Point to the next resource structure */
693
694         ResourceList = ACPI_PTR_ADD (ACPI_RESOURCE, ResourceList,
695                             ResourceList->Length);
696
697         /* Exit when END_TAG descriptor is reached */
698
699     } while (Type != ACPI_RESOURCE_TYPE_END_TAG);
700 }
701
702
703 /*******************************************************************************
704  *
705  * FUNCTION:    AcpiRsDumpIrqList
706  *
707  * PARAMETERS:  RouteTable      - Pointer to the routing table to dump.
708  *
709  * RETURN:      None
710  *
711  * DESCRIPTION: Print IRQ routing table
712  *
713  ******************************************************************************/
714
715 void
716 AcpiRsDumpIrqList (
717     UINT8                   *RouteTable)
718 {
719     ACPI_PCI_ROUTING_TABLE  *PrtElement;
720     UINT8                   Count;
721
722
723     ACPI_FUNCTION_ENTRY ();
724
725
726     if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
727     {
728         return;
729     }
730
731     PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
732
733     /* Dump all table elements, Exit on zero length element */
734
735     for (Count = 0; PrtElement->Length; Count++)
736     {
737         AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
738         AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
739
740         PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE,
741                         ((UINT8 *) PrtElement) + PrtElement->Length);
742     }
743 }
744
745
746 /*******************************************************************************
747  *
748  * FUNCTION:    AcpiRsOut*
749  *
750  * PARAMETERS:  Title       - Name of the resource field
751  *              Value       - Value of the resource field
752  *
753  * RETURN:      None
754  *
755  * DESCRIPTION: Miscellaneous helper functions to consistently format the
756  *              output of the resource dump routines
757  *
758  ******************************************************************************/
759
760 static void
761 AcpiRsOutString (
762     char                    *Title,
763     char                    *Value)
764 {
765     AcpiOsPrintf ("%27s : %s\n", Title, Value);
766 }
767
768 static void
769 AcpiRsOutInteger8 (
770     char                    *Title,
771     UINT8                   Value)
772 {
773     AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
774 }
775
776 static void
777 AcpiRsOutInteger16 (
778     char                    *Title,
779     UINT16                  Value)
780 {
781     AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
782 }
783
784 static void
785 AcpiRsOutInteger32 (
786     char                    *Title,
787     UINT32                  Value)
788 {
789     AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
790 }
791
792 static void
793 AcpiRsOutInteger64 (
794     char                    *Title,
795     UINT64                  Value)
796 {
797     AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
798         ACPI_FORMAT_UINT64 (Value));
799 }
800
801 static void
802 AcpiRsOutTitle (
803     char                    *Title)
804 {
805     AcpiOsPrintf ("%27s : ", Title);
806 }
807
808
809 /*******************************************************************************
810  *
811  * FUNCTION:    AcpiRsDump*List
812  *
813  * PARAMETERS:  Length      - Number of elements in the list
814  *              Data        - Start of the list
815  *
816  * RETURN:      None
817  *
818  * DESCRIPTION: Miscellaneous functions to dump lists of raw data
819  *
820  ******************************************************************************/
821
822 static void
823 AcpiRsDumpByteList (
824     UINT16                  Length,
825     UINT8                   *Data)
826 {
827     UINT8                   i;
828
829
830     for (i = 0; i < Length; i++)
831     {
832         AcpiOsPrintf ("%25s%2.2X : %2.2X\n",
833             "Byte", i, Data[i]);
834     }
835 }
836
837 static void
838 AcpiRsDumpShortByteList (
839     UINT8                  Length,
840     UINT8                  *Data)
841 {
842     UINT8                   i;
843
844
845     for (i = 0; i < Length; i++)
846     {
847         AcpiOsPrintf ("%X ", Data[i]);
848     }
849     AcpiOsPrintf ("\n");
850 }
851
852 static void
853 AcpiRsDumpDwordList (
854     UINT8                   Length,
855     UINT32                  *Data)
856 {
857     UINT8                   i;
858
859
860     for (i = 0; i < Length; i++)
861     {
862         AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
863             "Dword", i, Data[i]);
864     }
865 }
866
867 #endif
868