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