xref: /titanic_44/usr/src/uts/intel/io/acpica/resources/rsdump.c (revision f5c2e7ea56aaa46a9976476fb0cb1f02b9426f07)
1 /*******************************************************************************
2  *
3  * Module Name: rsdump - Functions to display the resource structures.
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2011, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 
45 #define __RSDUMP_C__
46 
47 #include "acpi.h"
48 #include "accommon.h"
49 #include "acresrc.h"
50 
51 #define _COMPONENT          ACPI_RESOURCES
52         ACPI_MODULE_NAME    ("rsdump")
53 
54 
55 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
56 
57 /* Local prototypes */
58 
59 static void
60 AcpiRsOutString (
61     char                    *Title,
62     char                    *Value);
63 
64 static void
65 AcpiRsOutInteger8 (
66     char                    *Title,
67     UINT8                   Value);
68 
69 static void
70 AcpiRsOutInteger16 (
71     char                    *Title,
72     UINT16                  Value);
73 
74 static void
75 AcpiRsOutInteger32 (
76     char                    *Title,
77     UINT32                  Value);
78 
79 static void
80 AcpiRsOutInteger64 (
81     char                    *Title,
82     UINT64                  Value);
83 
84 static void
85 AcpiRsOutTitle (
86     char                    *Title);
87 
88 static void
89 AcpiRsDumpByteList (
90     UINT16                  Length,
91     UINT8                   *Data);
92 
93 static void
94 AcpiRsDumpDwordList (
95     UINT8                   Length,
96     UINT32                  *Data);
97 
98 static void
99 AcpiRsDumpShortByteList (
100     UINT8                  Length,
101     UINT8                  *Data);
102 
103 static void
104 AcpiRsDumpResourceSource (
105     ACPI_RESOURCE_SOURCE    *ResourceSource);
106 
107 static void
108 AcpiRsDumpAddressCommon (
109     ACPI_RESOURCE_DATA      *Resource);
110 
111 static void
112 AcpiRsDumpDescriptor (
113     void                    *Resource,
114     ACPI_RSDUMP_INFO *Table);
115 
116 
117 #define ACPI_RSD_OFFSET(f)          (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f)
118 #define ACPI_PRT_OFFSET(f)          (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f)
119 #define ACPI_RSD_TABLE_SIZE(name)   (sizeof(name) / sizeof (ACPI_RSDUMP_INFO))
120 
121 
122 /*******************************************************************************
123  *
124  * Resource Descriptor info tables
125  *
126  * Note: The first table entry must be a Title or Literal and must contain
127  * the table length (number of table entries)
128  *
129  ******************************************************************************/
130 
131 ACPI_RSDUMP_INFO        AcpiRsDumpIrq[7] =
132 {
133     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq),                "IRQ",                      NULL},
134     {ACPI_RSD_UINT8 ,   ACPI_RSD_OFFSET (Irq.DescriptorLength),             "Descriptor Length",        NULL},
135     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering),                   "Triggering",               AcpiGbl_HeDecode},
136     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity),                     "Polarity",                 AcpiGbl_LlDecode},
137     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable),                     "Sharing",                  AcpiGbl_ShrDecode},
138     {ACPI_RSD_UINT8 ,   ACPI_RSD_OFFSET (Irq.InterruptCount),               "Interrupt Count",          NULL},
139     {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]),                "Interrupt List",           NULL}
140 };
141 
142 ACPI_RSDUMP_INFO        AcpiRsDumpDma[6] =
143 {
144     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma),                "DMA",                      NULL},
145     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type),                         "Speed",                    AcpiGbl_TypDecode},
146     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster),                    "Mastering",                AcpiGbl_BmDecode},
147     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer),                     "Transfer Type",            AcpiGbl_SizDecode},
148     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (Dma.ChannelCount),                 "Channel Count",            NULL},
149     {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]),                  "Channel List",             NULL}
150 };
151 
152 ACPI_RSDUMP_INFO        AcpiRsDumpStartDpf[4] =
153 {
154     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf),           "Start-Dependent-Functions",NULL},
155     {ACPI_RSD_UINT8 ,   ACPI_RSD_OFFSET (StartDpf.DescriptorLength),        "Descriptor Length",        NULL},
156     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority),   "Compatibility Priority",   AcpiGbl_ConfigDecode},
157     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness),   "Performance/Robustness",   AcpiGbl_ConfigDecode}
158 };
159 
160 ACPI_RSDUMP_INFO        AcpiRsDumpEndDpf[1] =
161 {
162     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf),             "End-Dependent-Functions",  NULL}
163 };
164 
165 ACPI_RSDUMP_INFO        AcpiRsDumpIo[6] =
166 {
167     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo),                 "I/O",                      NULL},
168     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode),                      "Address Decoding",         AcpiGbl_IoDecode},
169     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Io.Minimum),                       "Address Minimum",          NULL},
170     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Io.Maximum),                       "Address Maximum",          NULL},
171     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (Io.Alignment),                     "Alignment",                NULL},
172     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (Io.AddressLength),                 "Address Length",           NULL}
173 };
174 
175 ACPI_RSDUMP_INFO        AcpiRsDumpFixedIo[3] =
176 {
177     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo),            "Fixed I/O",                NULL},
178     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (FixedIo.Address),                  "Address",                  NULL},
179     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (FixedIo.AddressLength),            "Address Length",           NULL}
180 };
181 
182 ACPI_RSDUMP_INFO        AcpiRsDumpVendor[3] =
183 {
184     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor),             "Vendor Specific",          NULL},
185     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Vendor.ByteLength),                "Length",                   NULL},
186     {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]),               "Vendor Data",              NULL}
187 };
188 
189 ACPI_RSDUMP_INFO        AcpiRsDumpEndTag[1] =
190 {
191     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag),             "EndTag",                   NULL}
192 };
193 
194 ACPI_RSDUMP_INFO        AcpiRsDumpMemory24[6] =
195 {
196     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24),           "24-Bit Memory Range",      NULL},
197     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect),            "Write Protect",            AcpiGbl_RwDecode},
198     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.Minimum),                 "Address Minimum",          NULL},
199     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.Maximum),                 "Address Maximum",          NULL},
200     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.Alignment),               "Alignment",                NULL},
201     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Memory24.AddressLength),           "Address Length",           NULL}
202 };
203 
204 ACPI_RSDUMP_INFO        AcpiRsDumpMemory32[6] =
205 {
206     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32),           "32-Bit Memory Range",      NULL},
207     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect),            "Write Protect",            AcpiGbl_RwDecode},
208     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.Minimum),                 "Address Minimum",          NULL},
209     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.Maximum),                 "Address Maximum",          NULL},
210     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.Alignment),               "Alignment",                NULL},
211     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Memory32.AddressLength),           "Address Length",           NULL}
212 };
213 
214 ACPI_RSDUMP_INFO        AcpiRsDumpFixedMemory32[4] =
215 {
216     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32),      "32-Bit Fixed Memory Range",NULL},
217     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect),       "Write Protect",            AcpiGbl_RwDecode},
218     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (FixedMemory32.Address),            "Address",                  NULL},
219     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (FixedMemory32.AddressLength),      "Address Length",           NULL}
220 };
221 
222 ACPI_RSDUMP_INFO        AcpiRsDumpAddress16[8] =
223 {
224     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16),          "16-Bit WORD Address Space",NULL},
225     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
226     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.Granularity),            "Granularity",              NULL},
227     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.Minimum),                "Address Minimum",          NULL},
228     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.Maximum),                "Address Maximum",          NULL},
229     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.TranslationOffset),      "Translation Offset",       NULL},
230     {ACPI_RSD_UINT16,   ACPI_RSD_OFFSET (Address16.AddressLength),          "Address Length",           NULL},
231     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (Address16.ResourceSource),         NULL,                       NULL}
232 };
233 
234 ACPI_RSDUMP_INFO        AcpiRsDumpAddress32[8] =
235 {
236     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32),         "32-Bit DWORD Address Space", NULL},
237     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
238     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.Granularity),            "Granularity",              NULL},
239     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.Minimum),                "Address Minimum",          NULL},
240     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.Maximum),                "Address Maximum",          NULL},
241     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.TranslationOffset),      "Translation Offset",       NULL},
242     {ACPI_RSD_UINT32,   ACPI_RSD_OFFSET (Address32.AddressLength),          "Address Length",           NULL},
243     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (Address32.ResourceSource),         NULL,                       NULL}
244 };
245 
246 ACPI_RSDUMP_INFO        AcpiRsDumpAddress64[8] =
247 {
248     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64),          "64-Bit QWORD Address Space", NULL},
249     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
250     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.Granularity),            "Granularity",              NULL},
251     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.Minimum),                "Address Minimum",          NULL},
252     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.Maximum),                "Address Maximum",          NULL},
253     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.TranslationOffset),      "Translation Offset",       NULL},
254     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (Address64.AddressLength),          "Address Length",           NULL},
255     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (Address64.ResourceSource),         NULL,                       NULL}
256 };
257 
258 ACPI_RSDUMP_INFO        AcpiRsDumpExtAddress64[8] =
259 {
260     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64),       "64-Bit Extended Address Space", NULL},
261     {ACPI_RSD_ADDRESS,  0,                                                  NULL,                       NULL},
262     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.Granularity),         "Granularity",              NULL},
263     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.Minimum),             "Address Minimum",          NULL},
264     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.Maximum),             "Address Maximum",          NULL},
265     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset),   "Translation Offset",       NULL},
266     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.AddressLength),       "Address Length",           NULL},
267     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific),        "Type-Specific Attribute",  NULL}
268 };
269 
270 ACPI_RSDUMP_INFO        AcpiRsDumpExtIrq[8] =
271 {
272     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq),             "Extended IRQ",             NULL},
273     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer),     "Type",                     AcpiGbl_ConsumeDecode},
274     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering),           "Triggering",               AcpiGbl_HeDecode},
275     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity),             "Polarity",                 AcpiGbl_LlDecode},
276     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable),             "Sharing",                  AcpiGbl_ShrDecode},
277     {ACPI_RSD_SOURCE,   ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource),       NULL,                       NULL},
278     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount),       "Interrupt Count",          NULL},
279     {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]),        "Interrupt List",           NULL}
280 };
281 
282 ACPI_RSDUMP_INFO        AcpiRsDumpGenericReg[6] =
283 {
284     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg),         "Generic Register",         NULL},
285     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.SpaceId),               "Space ID",                 NULL},
286     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.BitWidth),              "Bit Width",                NULL},
287     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.BitOffset),             "Bit Offset",               NULL},
288     {ACPI_RSD_UINT8,    ACPI_RSD_OFFSET (GenericReg.AccessSize),            "Access Size",              NULL},
289     {ACPI_RSD_UINT64,   ACPI_RSD_OFFSET (GenericReg.Address),               "Address",                  NULL}
290 };
291 
292 
293 /*
294  * Tables used for common address descriptor flag fields
295  */
296 static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] =
297 {
298     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags),       NULL,                       NULL},
299     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer),         "Consumer/Producer",        AcpiGbl_ConsumeDecode},
300     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode),                   "Address Decode",           AcpiGbl_DecDecode},
301     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed),          "Min Relocatability",       AcpiGbl_MinDecode},
302     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed),          "Max Relocatability",       AcpiGbl_MaxDecode}
303 };
304 
305 static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] =
306 {
307     {ACPI_RSD_LITERAL,  ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags),        "Resource Type",            (void *) "Memory Range"},
308     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect),    "Write Protect",            AcpiGbl_RwDecode},
309     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching),         "Caching",                  AcpiGbl_MemDecode},
310     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType),       "Range Type",               AcpiGbl_MtpDecode},
311     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation),     "Translation",              AcpiGbl_TtpDecode}
312 };
313 
314 static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] =
315 {
316     {ACPI_RSD_LITERAL,  ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags),            "Resource Type",            (void *) "I/O Range"},
317     {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType),        "Range Type",               AcpiGbl_RngDecode},
318     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation),      "Translation",              AcpiGbl_TtpDecode},
319     {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType),  "Translation Type",         AcpiGbl_TrsDecode}
320 };
321 
322 
323 /*
324  * Table used to dump _PRT contents
325  */
326 static ACPI_RSDUMP_INFO   AcpiRsDumpPrt[5] =
327 {
328     {ACPI_RSD_TITLE,    ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt),                NULL,                       NULL},
329     {ACPI_RSD_UINT64,   ACPI_PRT_OFFSET (Address),                          "Address",                  NULL},
330     {ACPI_RSD_UINT32,   ACPI_PRT_OFFSET (Pin),                              "Pin",                      NULL},
331     {ACPI_RSD_STRING,   ACPI_PRT_OFFSET (Source[0]),                        "Source",                   NULL},
332     {ACPI_RSD_UINT32,   ACPI_PRT_OFFSET (SourceIndex),                      "Source Index",             NULL}
333 };
334 
335 
336 /*******************************************************************************
337  *
338  * FUNCTION:    AcpiRsDumpDescriptor
339  *
340  * PARAMETERS:  Resource
341  *
342  * RETURN:      None
343  *
344  * DESCRIPTION:
345  *
346  ******************************************************************************/
347 
348 static void
349 AcpiRsDumpDescriptor (
350     void                    *Resource,
351     ACPI_RSDUMP_INFO        *Table)
352 {
353     UINT8                   *Target = NULL;
354     UINT8                   *PreviousTarget;
355     char                    *Name;
356     UINT8                    Count;
357 
358 
359     /* First table entry must contain the table length (# of table entries) */
360 
361     Count = Table->Offset;
362 
363     while (Count)
364     {
365         PreviousTarget = Target;
366         Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset);
367         Name = Table->Name;
368 
369         switch (Table->Opcode)
370         {
371         case ACPI_RSD_TITLE:
372             /*
373              * Optional resource title
374              */
375             if (Table->Name)
376             {
377                 AcpiOsPrintf ("%s Resource\n", Name);
378             }
379             break;
380 
381         /* Strings */
382 
383         case ACPI_RSD_LITERAL:
384             AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer));
385             break;
386 
387         case ACPI_RSD_STRING:
388             AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target));
389             break;
390 
391         /* Data items, 8/16/32/64 bit */
392 
393         case ACPI_RSD_UINT8:
394             AcpiRsOutInteger8 (Name, ACPI_GET8 (Target));
395             break;
396 
397         case ACPI_RSD_UINT16:
398             AcpiRsOutInteger16 (Name, ACPI_GET16 (Target));
399             break;
400 
401         case ACPI_RSD_UINT32:
402             AcpiRsOutInteger32 (Name, ACPI_GET32 (Target));
403             break;
404 
405         case ACPI_RSD_UINT64:
406             AcpiRsOutInteger64 (Name, ACPI_GET64 (Target));
407             break;
408 
409         /* Flags: 1-bit and 2-bit flags supported */
410 
411         case ACPI_RSD_1BITFLAG:
412             AcpiRsOutString (Name, ACPI_CAST_PTR (char,
413                 Table->Pointer [*Target & 0x01]));
414             break;
415 
416         case ACPI_RSD_2BITFLAG:
417             AcpiRsOutString (Name, ACPI_CAST_PTR (char,
418                 Table->Pointer [*Target & 0x03]));
419             break;
420 
421         case ACPI_RSD_SHORTLIST:
422             /*
423              * Short byte list (single line output) for DMA and IRQ resources
424              * Note: The list length is obtained from the previous table entry
425              */
426             if (PreviousTarget)
427             {
428                 AcpiRsOutTitle (Name);
429                 AcpiRsDumpShortByteList (*PreviousTarget, Target);
430             }
431             break;
432 
433         case ACPI_RSD_LONGLIST:
434             /*
435              * Long byte list for Vendor resource data
436              * Note: The list length is obtained from the previous table entry
437              */
438             if (PreviousTarget)
439             {
440                 AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target);
441             }
442             break;
443 
444         case ACPI_RSD_DWORDLIST:
445             /*
446              * Dword list for Extended Interrupt resources
447              * Note: The list length is obtained from the previous table entry
448              */
449             if (PreviousTarget)
450             {
451                 AcpiRsDumpDwordList (*PreviousTarget,
452                     ACPI_CAST_PTR (UINT32, Target));
453             }
454             break;
455 
456         case ACPI_RSD_ADDRESS:
457             /*
458              * Common flags for all Address resources
459              */
460             AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target));
461             break;
462 
463         case ACPI_RSD_SOURCE:
464             /*
465              * Optional ResourceSource for Address resources
466              */
467             AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target));
468             break;
469 
470         default:
471             AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
472                 Table->Opcode);
473             return;
474         }
475 
476         Table++;
477         Count--;
478     }
479 }
480 
481 
482 /*******************************************************************************
483  *
484  * FUNCTION:    AcpiRsDumpResourceSource
485  *
486  * PARAMETERS:  ResourceSource      - Pointer to a Resource Source struct
487  *
488  * RETURN:      None
489  *
490  * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
491  *              corresponding ResourceSourceIndex.
492  *
493  ******************************************************************************/
494 
495 static void
496 AcpiRsDumpResourceSource (
497     ACPI_RESOURCE_SOURCE    *ResourceSource)
498 {
499     ACPI_FUNCTION_ENTRY ();
500 
501 
502     if (ResourceSource->Index == 0xFF)
503     {
504         return;
505     }
506 
507     AcpiRsOutInteger8 ("Resource Source Index",
508         ResourceSource->Index);
509 
510     AcpiRsOutString ("Resource Source",
511         ResourceSource->StringPtr ?
512             ResourceSource->StringPtr : "[Not Specified]");
513 }
514 
515 
516 /*******************************************************************************
517  *
518  * FUNCTION:    AcpiRsDumpAddressCommon
519  *
520  * PARAMETERS:  Resource        - Pointer to an internal resource descriptor
521  *
522  * RETURN:      None
523  *
524  * DESCRIPTION: Dump the fields that are common to all Address resource
525  *              descriptors
526  *
527  ******************************************************************************/
528 
529 static void
530 AcpiRsDumpAddressCommon (
531     ACPI_RESOURCE_DATA      *Resource)
532 {
533     ACPI_FUNCTION_ENTRY ();
534 
535 
536    /* Decode the type-specific flags */
537 
538     switch (Resource->Address.ResourceType)
539     {
540     case ACPI_MEMORY_RANGE:
541 
542         AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
543         break;
544 
545     case ACPI_IO_RANGE:
546 
547         AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
548         break;
549 
550     case ACPI_BUS_NUMBER_RANGE:
551 
552         AcpiRsOutString ("Resource Type", "Bus Number Range");
553         break;
554 
555     default:
556 
557         AcpiRsOutInteger8 ("Resource Type",
558             (UINT8) Resource->Address.ResourceType);
559         break;
560     }
561 
562     /* Decode the general flags */
563 
564     AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
565 }
566 
567 
568 /*******************************************************************************
569  *
570  * FUNCTION:    AcpiRsDumpResourceList
571  *
572  * PARAMETERS:  ResourceList        - Pointer to a resource descriptor list
573  *
574  * RETURN:      None
575  *
576  * DESCRIPTION: Dispatches the structure to the correct dump routine.
577  *
578  ******************************************************************************/
579 
580 void
581 AcpiRsDumpResourceList (
582     ACPI_RESOURCE           *ResourceList)
583 {
584     UINT32                  Count = 0;
585     UINT32                  Type;
586 
587 
588     ACPI_FUNCTION_ENTRY ();
589 
590 
591     if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
592     {
593         return;
594     }
595 
596     /* Walk list and dump all resource descriptors (END_TAG terminates) */
597 
598     do
599     {
600         AcpiOsPrintf ("\n[%02X] ", Count);
601         Count++;
602 
603         /* Validate Type before dispatch */
604 
605         Type = ResourceList->Type;
606         if (Type > ACPI_RESOURCE_TYPE_MAX)
607         {
608             AcpiOsPrintf (
609                 "Invalid descriptor type (%X) in resource list\n",
610                 ResourceList->Type);
611             return;
612         }
613 
614         /* Dump the resource descriptor */
615 
616         AcpiRsDumpDescriptor (&ResourceList->Data,
617             AcpiGbl_DumpResourceDispatch[Type]);
618 
619         /* Point to the next resource structure */
620 
621         ResourceList = ACPI_ADD_PTR (ACPI_RESOURCE, ResourceList,
622                             ResourceList->Length);
623 
624         /* Exit when END_TAG descriptor is reached */
625 
626     } while (Type != ACPI_RESOURCE_TYPE_END_TAG);
627 }
628 
629 
630 /*******************************************************************************
631  *
632  * FUNCTION:    AcpiRsDumpIrqList
633  *
634  * PARAMETERS:  RouteTable      - Pointer to the routing table to dump.
635  *
636  * RETURN:      None
637  *
638  * DESCRIPTION: Print IRQ routing table
639  *
640  ******************************************************************************/
641 
642 void
643 AcpiRsDumpIrqList (
644     UINT8                   *RouteTable)
645 {
646     ACPI_PCI_ROUTING_TABLE  *PrtElement;
647     UINT8                   Count;
648 
649 
650     ACPI_FUNCTION_ENTRY ();
651 
652 
653     if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
654     {
655         return;
656     }
657 
658     PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
659 
660     /* Dump all table elements, Exit on zero length element */
661 
662     for (Count = 0; PrtElement->Length; Count++)
663     {
664         AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
665         AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
666 
667         PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE,
668                         PrtElement, PrtElement->Length);
669     }
670 }
671 
672 
673 /*******************************************************************************
674  *
675  * FUNCTION:    AcpiRsOut*
676  *
677  * PARAMETERS:  Title       - Name of the resource field
678  *              Value       - Value of the resource field
679  *
680  * RETURN:      None
681  *
682  * DESCRIPTION: Miscellaneous helper functions to consistently format the
683  *              output of the resource dump routines
684  *
685  ******************************************************************************/
686 
687 static void
688 AcpiRsOutString (
689     char                    *Title,
690     char                    *Value)
691 {
692     AcpiOsPrintf ("%27s : %s", Title, Value);
693     if (!*Value)
694     {
695         AcpiOsPrintf ("[NULL NAMESTRING]");
696     }
697     AcpiOsPrintf ("\n");
698 }
699 
700 static void
701 AcpiRsOutInteger8 (
702     char                    *Title,
703     UINT8                   Value)
704 {
705     AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
706 }
707 
708 static void
709 AcpiRsOutInteger16 (
710     char                    *Title,
711     UINT16                  Value)
712 {
713     AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
714 }
715 
716 static void
717 AcpiRsOutInteger32 (
718     char                    *Title,
719     UINT32                  Value)
720 {
721     AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
722 }
723 
724 static void
725 AcpiRsOutInteger64 (
726     char                    *Title,
727     UINT64                  Value)
728 {
729     AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
730         ACPI_FORMAT_UINT64 (Value));
731 }
732 
733 static void
734 AcpiRsOutTitle (
735     char                    *Title)
736 {
737     AcpiOsPrintf ("%27s : ", Title);
738 }
739 
740 
741 /*******************************************************************************
742  *
743  * FUNCTION:    AcpiRsDump*List
744  *
745  * PARAMETERS:  Length      - Number of elements in the list
746  *              Data        - Start of the list
747  *
748  * RETURN:      None
749  *
750  * DESCRIPTION: Miscellaneous functions to dump lists of raw data
751  *
752  ******************************************************************************/
753 
754 static void
755 AcpiRsDumpByteList (
756     UINT16                  Length,
757     UINT8                   *Data)
758 {
759     UINT8                   i;
760 
761 
762     for (i = 0; i < Length; i++)
763     {
764         AcpiOsPrintf ("%25s%2.2X : %2.2X\n",
765             "Byte", i, Data[i]);
766     }
767 }
768 
769 static void
770 AcpiRsDumpShortByteList (
771     UINT8                  Length,
772     UINT8                  *Data)
773 {
774     UINT8                   i;
775 
776 
777     for (i = 0; i < Length; i++)
778     {
779         AcpiOsPrintf ("%X ", Data[i]);
780     }
781     AcpiOsPrintf ("\n");
782 }
783 
784 static void
785 AcpiRsDumpDwordList (
786     UINT8                   Length,
787     UINT32                  *Data)
788 {
789     UINT8                   i;
790 
791 
792     for (i = 0; i < Length; i++)
793     {
794         AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
795             "Dword", i, Data[i]);
796     }
797 }
798 
799 #endif
800 
801