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