Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[linux-2.6] / drivers / acpi / resources / rsdump.c
1 /*******************************************************************************
2  *
3  * Module Name: rsdump - Functions to display the resource structures.
4  *
5  ******************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2006, R. Byron Moore
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 #include <acpi/acpi.h>
45 #include <acpi/acresrc.h>
46
47 #define _COMPONENT          ACPI_RESOURCES
48 ACPI_MODULE_NAME("rsdump")
49
50 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
51 /* Local prototypes */
52 static void acpi_rs_out_string(char *title, char *value);
53
54 static void acpi_rs_out_integer8(char *title, u8 value);
55
56 static void acpi_rs_out_integer16(char *title, u16 value);
57
58 static void acpi_rs_out_integer32(char *title, u32 value);
59
60 static void acpi_rs_out_integer64(char *title, u64 value);
61
62 static void acpi_rs_out_title(char *title);
63
64 static void acpi_rs_dump_byte_list(u16 length, u8 * data);
65
66 static void acpi_rs_dump_dword_list(u8 length, u32 * data);
67
68 static void acpi_rs_dump_short_byte_list(u8 length, u8 * data);
69
70 static void
71 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
72
73 static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
74
75 static void
76 acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
77
78 #define ACPI_RSD_OFFSET(f)          (u8) ACPI_OFFSET (union acpi_resource_data,f)
79 #define ACPI_PRT_OFFSET(f)          (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
80 #define ACPI_RSD_TABLE_SIZE(name)   (sizeof(name) / sizeof (struct acpi_rsdump_info))
81
82 /*******************************************************************************
83  *
84  * Resource Descriptor info tables
85  *
86  * Note: The first table entry must be a Title or Literal and must contain
87  * the table length (number of table entries)
88  *
89  ******************************************************************************/
90
91 struct acpi_rsdump_info acpi_rs_dump_irq[6] = {
92         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
93         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
94          acpi_gbl_HEdecode},
95         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
96          acpi_gbl_LLdecode},
97         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
98          acpi_gbl_SHRdecode},
99         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count),
100          "Interrupt Count", NULL},
101         {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]),
102          "Interrupt List", NULL}
103 };
104
105 struct acpi_rsdump_info acpi_rs_dump_dma[6] = {
106         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL},
107         {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed",
108          acpi_gbl_TYPdecode},
109         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
110          acpi_gbl_BMdecode},
111         {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
112          acpi_gbl_SIZdecode},
113         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count",
114          NULL},
115         {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List",
116          NULL}
117 };
118
119 struct acpi_rsdump_info acpi_rs_dump_start_dpf[3] = {
120         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
121          "Start-Dependent-Functions", NULL},
122         {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority),
123          "Compatibility Priority", acpi_gbl_config_decode},
124         {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness),
125          "Performance/Robustness", acpi_gbl_config_decode}
126 };
127
128 struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = {
129         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf),
130          "End-Dependent-Functions", NULL}
131 };
132
133 struct acpi_rsdump_info acpi_rs_dump_io[6] = {
134         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL},
135         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding",
136          acpi_gbl_io_decode},
137         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL},
138         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL},
139         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL},
140         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length",
141          NULL}
142 };
143
144 struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = {
145         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io),
146          "Fixed I/O", NULL},
147         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL},
148         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length),
149          "Address Length", NULL}
150 };
151
152 struct acpi_rsdump_info acpi_rs_dump_vendor[3] = {
153         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor),
154          "Vendor Specific", NULL},
155         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL},
156         {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data",
157          NULL}
158 };
159
160 struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = {
161         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "end_tag",
162          NULL}
163 };
164
165 struct acpi_rsdump_info acpi_rs_dump_memory24[6] = {
166         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24),
167          "24-Bit Memory Range", NULL},
168         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect),
169          "Write Protect", acpi_gbl_RWdecode},
170         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum",
171          NULL},
172         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum",
173          NULL},
174         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment",
175          NULL},
176         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length),
177          "Address Length", NULL}
178 };
179
180 struct acpi_rsdump_info acpi_rs_dump_memory32[6] = {
181         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32),
182          "32-Bit Memory Range", NULL},
183         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect),
184          "Write Protect", acpi_gbl_RWdecode},
185         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum",
186          NULL},
187         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum",
188          NULL},
189         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment",
190          NULL},
191         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length),
192          "Address Length", NULL}
193 };
194
195 struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = {
196         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32),
197          "32-Bit Fixed Memory Range", NULL},
198         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect),
199          "Write Protect", acpi_gbl_RWdecode},
200         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address",
201          NULL},
202         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length),
203          "Address Length", NULL}
204 };
205
206 struct acpi_rsdump_info acpi_rs_dump_address16[8] = {
207         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16),
208          "16-Bit WORD Address Space", NULL},
209         {ACPI_RSD_ADDRESS, 0, NULL, NULL},
210         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity",
211          NULL},
212         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum",
213          NULL},
214         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum",
215          NULL},
216         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset),
217          "Translation Offset", NULL},
218         {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length),
219          "Address Length", NULL},
220         {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL}
221 };
222
223 struct acpi_rsdump_info acpi_rs_dump_address32[8] = {
224         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32),
225          "32-Bit DWORD Address Space", NULL},
226         {ACPI_RSD_ADDRESS, 0, NULL, NULL},
227         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity",
228          NULL},
229         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum",
230          NULL},
231         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum",
232          NULL},
233         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset),
234          "Translation Offset", NULL},
235         {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length),
236          "Address Length", NULL},
237         {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL}
238 };
239
240 struct acpi_rsdump_info acpi_rs_dump_address64[8] = {
241         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64),
242          "64-Bit QWORD Address Space", NULL},
243         {ACPI_RSD_ADDRESS, 0, NULL, NULL},
244         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity",
245          NULL},
246         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum",
247          NULL},
248         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum",
249          NULL},
250         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset),
251          "Translation Offset", NULL},
252         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length),
253          "Address Length", NULL},
254         {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL}
255 };
256
257 struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = {
258         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64),
259          "64-Bit Extended Address Space", NULL},
260         {ACPI_RSD_ADDRESS, 0, NULL, NULL},
261         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity),
262          "Granularity", NULL},
263         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum),
264          "Address Minimum", NULL},
265         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum),
266          "Address Maximum", NULL},
267         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset),
268          "Translation Offset", NULL},
269         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length),
270          "Address Length", NULL},
271         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific),
272          "Type-Specific Attribute", NULL}
273 };
274
275 struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = {
276         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq),
277          "Extended IRQ", NULL},
278         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer),
279          "Type", acpi_gbl_consume_decode},
280         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering),
281          "Triggering", acpi_gbl_HEdecode},
282         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
283          acpi_gbl_LLdecode},
284         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
285          acpi_gbl_SHRdecode},
286         {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL,
287          NULL},
288         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count),
289          "Interrupt Count", NULL},
290         {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]),
291          "Interrupt List", NULL}
292 };
293
294 struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = {
295         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg),
296          "Generic Register", NULL},
297         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID",
298          NULL},
299         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width",
300          NULL},
301         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset",
302          NULL},
303         {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size),
304          "Access Size", NULL},
305         {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL}
306 };
307
308 /*
309  * Tables used for common address descriptor flag fields
310  */
311 static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = {
312         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL,
313          NULL},
314         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer),
315          "Consumer/Producer", acpi_gbl_consume_decode},
316         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode",
317          acpi_gbl_DECdecode},
318         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed),
319          "Min Relocatability", acpi_gbl_min_decode},
320         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed),
321          "Max Relocatability", acpi_gbl_max_decode}
322 };
323
324 static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
325         {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags),
326          "Resource Type", (void *)"Memory Range"},
327         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
328          "Write Protect", acpi_gbl_RWdecode},
329         {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
330          "Caching", acpi_gbl_MEMdecode},
331         {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
332          "Range Type", acpi_gbl_MTPdecode},
333         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
334          "Translation", acpi_gbl_TTPdecode}
335 };
336
337 static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
338         {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags),
339          "Resource Type", (void *)"I/O Range"},
340         {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
341          "Range Type", acpi_gbl_RNGdecode},
342         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
343          "Translation", acpi_gbl_TTPdecode},
344         {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
345          "Translation Type", acpi_gbl_TRSdecode}
346 };
347
348 /*
349  * Table used to dump _PRT contents
350  */
351 static struct acpi_rsdump_info acpi_rs_dump_prt[5] = {
352         {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL},
353         {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL},
354         {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL},
355         {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL},
356         {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL}
357 };
358
359 /*******************************************************************************
360  *
361  * FUNCTION:    acpi_rs_dump_descriptor
362  *
363  * PARAMETERS:  Resource
364  *
365  * RETURN:      None
366  *
367  * DESCRIPTION:
368  *
369  ******************************************************************************/
370
371 static void
372 acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
373 {
374         u8 *target = NULL;
375         u8 *previous_target;
376         char *name;
377         u8 count;
378
379         /* First table entry must contain the table length (# of table entries) */
380
381         count = table->offset;
382
383         while (count) {
384                 previous_target = target;
385                 target = ACPI_ADD_PTR(u8, resource, table->offset);
386                 name = table->name;
387
388                 switch (table->opcode) {
389                 case ACPI_RSD_TITLE:
390                         /*
391                          * Optional resource title
392                          */
393                         if (table->name) {
394                                 acpi_os_printf("%s Resource\n", name);
395                         }
396                         break;
397
398                         /* Strings */
399
400                 case ACPI_RSD_LITERAL:
401                         acpi_rs_out_string(name,
402                                            ACPI_CAST_PTR(char, table->pointer));
403                         break;
404
405                 case ACPI_RSD_STRING:
406                         acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
407                         break;
408
409                         /* Data items, 8/16/32/64 bit */
410
411                 case ACPI_RSD_UINT8:
412                         acpi_rs_out_integer8(name, ACPI_GET8(target));
413                         break;
414
415                 case ACPI_RSD_UINT16:
416                         acpi_rs_out_integer16(name, ACPI_GET16(target));
417                         break;
418
419                 case ACPI_RSD_UINT32:
420                         acpi_rs_out_integer32(name, ACPI_GET32(target));
421                         break;
422
423                 case ACPI_RSD_UINT64:
424                         acpi_rs_out_integer64(name, ACPI_GET64(target));
425                         break;
426
427                         /* Flags: 1-bit and 2-bit flags supported */
428
429                 case ACPI_RSD_1BITFLAG:
430                         acpi_rs_out_string(name, ACPI_CAST_PTR(char,
431                                                                table->
432                                                                pointer[*target &
433                                                                        0x01]));
434                         break;
435
436                 case ACPI_RSD_2BITFLAG:
437                         acpi_rs_out_string(name, ACPI_CAST_PTR(char,
438                                                                table->
439                                                                pointer[*target &
440                                                                        0x03]));
441                         break;
442
443                 case ACPI_RSD_SHORTLIST:
444                         /*
445                          * Short byte list (single line output) for DMA and IRQ resources
446                          * Note: The list length is obtained from the previous table entry
447                          */
448                         if (previous_target) {
449                                 acpi_rs_out_title(name);
450                                 acpi_rs_dump_short_byte_list(*previous_target,
451                                                              target);
452                         }
453                         break;
454
455                 case ACPI_RSD_LONGLIST:
456                         /*
457                          * Long byte list for Vendor resource data
458                          * Note: The list length is obtained from the previous table entry
459                          */
460                         if (previous_target) {
461                                 acpi_rs_dump_byte_list(ACPI_GET16
462                                                        (previous_target),
463                                                        target);
464                         }
465                         break;
466
467                 case ACPI_RSD_DWORDLIST:
468                         /*
469                          * Dword list for Extended Interrupt resources
470                          * Note: The list length is obtained from the previous table entry
471                          */
472                         if (previous_target) {
473                                 acpi_rs_dump_dword_list(*previous_target,
474                                                         ACPI_CAST_PTR(u32,
475                                                                       target));
476                         }
477                         break;
478
479                 case ACPI_RSD_ADDRESS:
480                         /*
481                          * Common flags for all Address resources
482                          */
483                         acpi_rs_dump_address_common(ACPI_CAST_PTR
484                                                     (union acpi_resource_data,
485                                                      target));
486                         break;
487
488                 case ACPI_RSD_SOURCE:
489                         /*
490                          * Optional resource_source for Address resources
491                          */
492                         acpi_rs_dump_resource_source(ACPI_CAST_PTR
493                                                      (struct
494                                                       acpi_resource_source,
495                                                       target));
496                         break;
497
498                 default:
499                         acpi_os_printf("**** Invalid table opcode [%X] ****\n",
500                                        table->opcode);
501                         return;
502                 }
503
504                 table++;
505                 count--;
506         }
507 }
508
509 /*******************************************************************************
510  *
511  * FUNCTION:    acpi_rs_dump_resource_source
512  *
513  * PARAMETERS:  resource_source     - Pointer to a Resource Source struct
514  *
515  * RETURN:      None
516  *
517  * DESCRIPTION: Common routine for dumping the optional resource_source and the
518  *              corresponding resource_source_index.
519  *
520  ******************************************************************************/
521
522 static void
523 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
524 {
525         ACPI_FUNCTION_ENTRY();
526
527         if (resource_source->index == 0xFF) {
528                 return;
529         }
530
531         acpi_rs_out_integer8("Resource Source Index", resource_source->index);
532
533         acpi_rs_out_string("Resource Source",
534                            resource_source->string_ptr ?
535                            resource_source->string_ptr : "[Not Specified]");
536 }
537
538 /*******************************************************************************
539  *
540  * FUNCTION:    acpi_rs_dump_address_common
541  *
542  * PARAMETERS:  Resource        - Pointer to an internal resource descriptor
543  *
544  * RETURN:      None
545  *
546  * DESCRIPTION: Dump the fields that are common to all Address resource
547  *              descriptors
548  *
549  ******************************************************************************/
550
551 static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
552 {
553         ACPI_FUNCTION_ENTRY();
554
555         /* Decode the type-specific flags */
556
557         switch (resource->address.resource_type) {
558         case ACPI_MEMORY_RANGE:
559
560                 acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags);
561                 break;
562
563         case ACPI_IO_RANGE:
564
565                 acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags);
566                 break;
567
568         case ACPI_BUS_NUMBER_RANGE:
569
570                 acpi_rs_out_string("Resource Type", "Bus Number Range");
571                 break;
572
573         default:
574
575                 acpi_rs_out_integer8("Resource Type",
576                                      (u8) resource->address.resource_type);
577                 break;
578         }
579
580         /* Decode the general flags */
581
582         acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags);
583 }
584
585 /*******************************************************************************
586  *
587  * FUNCTION:    acpi_rs_dump_resource_list
588  *
589  * PARAMETERS:  resource_list       - Pointer to a resource descriptor list
590  *
591  * RETURN:      None
592  *
593  * DESCRIPTION: Dispatches the structure to the correct dump routine.
594  *
595  ******************************************************************************/
596
597 void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
598 {
599         u32 count = 0;
600         u32 type;
601
602         ACPI_FUNCTION_ENTRY();
603
604         if (!(acpi_dbg_level & ACPI_LV_RESOURCES)
605             || !(_COMPONENT & acpi_dbg_layer)) {
606                 return;
607         }
608
609         /* Walk list and dump all resource descriptors (END_TAG terminates) */
610
611         do {
612                 acpi_os_printf("\n[%02X] ", count);
613                 count++;
614
615                 /* Validate Type before dispatch */
616
617                 type = resource_list->type;
618                 if (type > ACPI_RESOURCE_TYPE_MAX) {
619                         acpi_os_printf
620                             ("Invalid descriptor type (%X) in resource list\n",
621                              resource_list->type);
622                         return;
623                 }
624
625                 /* Dump the resource descriptor */
626
627                 acpi_rs_dump_descriptor(&resource_list->data,
628                                         acpi_gbl_dump_resource_dispatch[type]);
629
630                 /* Point to the next resource structure */
631
632                 resource_list =
633                     ACPI_ADD_PTR(struct acpi_resource, resource_list,
634                                  resource_list->length);
635
636                 /* Exit when END_TAG descriptor is reached */
637
638         } while (type != ACPI_RESOURCE_TYPE_END_TAG);
639 }
640
641 /*******************************************************************************
642  *
643  * FUNCTION:    acpi_rs_dump_irq_list
644  *
645  * PARAMETERS:  route_table     - Pointer to the routing table to dump.
646  *
647  * RETURN:      None
648  *
649  * DESCRIPTION: Print IRQ routing table
650  *
651  ******************************************************************************/
652
653 void acpi_rs_dump_irq_list(u8 * route_table)
654 {
655         struct acpi_pci_routing_table *prt_element;
656         u8 count;
657
658         ACPI_FUNCTION_ENTRY();
659
660         if (!(acpi_dbg_level & ACPI_LV_RESOURCES)
661             || !(_COMPONENT & acpi_dbg_layer)) {
662                 return;
663         }
664
665         prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table);
666
667         /* Dump all table elements, Exit on zero length element */
668
669         for (count = 0; prt_element->length; count++) {
670                 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
671                                count);
672                 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
673
674                 prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
675                                            prt_element, prt_element->length);
676         }
677 }
678
679 /*******************************************************************************
680  *
681  * FUNCTION:    acpi_rs_out*
682  *
683  * PARAMETERS:  Title       - Name of the resource field
684  *              Value       - Value of the resource field
685  *
686  * RETURN:      None
687  *
688  * DESCRIPTION: Miscellaneous helper functions to consistently format the
689  *              output of the resource dump routines
690  *
691  ******************************************************************************/
692
693 static void acpi_rs_out_string(char *title, char *value)
694 {
695         acpi_os_printf("%27s : %s", title, value);
696         if (!*value) {
697                 acpi_os_printf("[NULL NAMESTRING]");
698         }
699         acpi_os_printf("\n");
700 }
701
702 static void acpi_rs_out_integer8(char *title, u8 value)
703 {
704         acpi_os_printf("%27s : %2.2X\n", title, value);
705 }
706
707 static void acpi_rs_out_integer16(char *title, u16 value)
708 {
709         acpi_os_printf("%27s : %4.4X\n", title, value);
710 }
711
712 static void acpi_rs_out_integer32(char *title, u32 value)
713 {
714         acpi_os_printf("%27s : %8.8X\n", title, value);
715 }
716
717 static void acpi_rs_out_integer64(char *title, u64 value)
718 {
719         acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
720 }
721
722 static void acpi_rs_out_title(char *title)
723 {
724         acpi_os_printf("%27s : ", title);
725 }
726
727 /*******************************************************************************
728  *
729  * FUNCTION:    acpi_rs_dump*List
730  *
731  * PARAMETERS:  Length      - Number of elements in the list
732  *              Data        - Start of the list
733  *
734  * RETURN:      None
735  *
736  * DESCRIPTION: Miscellaneous functions to dump lists of raw data
737  *
738  ******************************************************************************/
739
740 static void acpi_rs_dump_byte_list(u16 length, u8 * data)
741 {
742         u8 i;
743
744         for (i = 0; i < length; i++) {
745                 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
746         }
747 }
748
749 static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
750 {
751         u8 i;
752
753         for (i = 0; i < length; i++) {
754                 acpi_os_printf("%X ", data[i]);
755         }
756         acpi_os_printf("\n");
757 }
758
759 static void acpi_rs_dump_dword_list(u8 length, u32 * data)
760 {
761         u8 i;
762
763         for (i = 0; i < length; i++) {
764                 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
765         }
766 }
767
768 #endif