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