blob: 33db7520c74be0c2937b837b31512dcec49fde58 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: rsdump - Functions to display the resource structures.
4 *
5 ******************************************************************************/
6
7/*
Bob Mooreb4e104e2011-01-17 11:05:40 +08008 * Copyright (C) 2000 - 2011, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acresrc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48#define _COMPONENT ACPI_RESOURCES
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("rsdump")
Robert Moore6f42ccf2005-05-13 00:00:00 -040050#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
Robert Moore44f6c012005-04-18 22:49:35 -040051/* Local prototypes */
Robert Moorebda663d2005-09-16 16:51:15 -040052static void acpi_rs_out_string(char *title, char *value);
53
54static void acpi_rs_out_integer8(char *title, u8 value);
55
56static void acpi_rs_out_integer16(char *title, u16 value);
57
58static void acpi_rs_out_integer32(char *title, u32 value);
59
60static void acpi_rs_out_integer64(char *title, u64 value);
61
62static void acpi_rs_out_title(char *title);
63
Bob Moore08978312005-10-21 00:00:00 -040064static void acpi_rs_dump_byte_list(u16 length, u8 * data);
Robert Moorebda663d2005-09-16 16:51:15 -040065
Bob Moore08978312005-10-21 00:00:00 -040066static void acpi_rs_dump_dword_list(u8 length, u32 * data);
Robert Moorebda663d2005-09-16 16:51:15 -040067
Bob Moore08978312005-10-21 00:00:00 -040068static void acpi_rs_dump_short_byte_list(u8 length, u8 * data);
Robert Moorebda663d2005-09-16 16:51:15 -040069
70static void
71acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
72
73static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
74
Bob Moore08978312005-10-21 00:00:00 -040075static void
76acpi_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
Bob Moore1d5b2852008-04-10 19:06:43 +040091struct acpi_rsdump_info acpi_rs_dump_irq[7] = {
Bob Moore08978312005-10-21 00:00:00 -040092 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
Bob Moore1d5b2852008-04-10 19:06:43 +040093 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.descriptor_length),
94 "Descriptor Length", NULL},
Bob Moore08978312005-10-21 00:00:00 -040095 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
Bob Mooreb229cf92006-04-21 17:15:00 -040096 acpi_gbl_he_decode},
Bob Moore08978312005-10-21 00:00:00 -040097 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
Bob Mooreb229cf92006-04-21 17:15:00 -040098 acpi_gbl_ll_decode},
Bob Moore08978312005-10-21 00:00:00 -040099 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
Bob Mooreb229cf92006-04-21 17:15:00 -0400100 acpi_gbl_shr_decode},
Bob Moore08978312005-10-21 00:00:00 -0400101 {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
107struct 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",
Bob Mooreb229cf92006-04-21 17:15:00 -0400110 acpi_gbl_typ_decode},
Bob Moore08978312005-10-21 00:00:00 -0400111 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
Bob Mooreb229cf92006-04-21 17:15:00 -0400112 acpi_gbl_bm_decode},
Bob Moore08978312005-10-21 00:00:00 -0400113 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
Bob Mooreb229cf92006-04-21 17:15:00 -0400114 acpi_gbl_siz_decode},
Bob Moore08978312005-10-21 00:00:00 -0400115 {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
Bob Moore1d5b2852008-04-10 19:06:43 +0400121struct acpi_rsdump_info acpi_rs_dump_start_dpf[4] = {
Bob Moore08978312005-10-21 00:00:00 -0400122 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
123 "Start-Dependent-Functions", NULL},
Bob Moore1d5b2852008-04-10 19:06:43 +0400124 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(start_dpf.descriptor_length),
125 "Descriptor Length", NULL},
Bob Moore08978312005-10-21 00:00:00 -0400126 {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
132struct 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
137struct 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
148struct 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
156struct 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
164struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = {
Bob Mooreb229cf92006-04-21 17:15:00 -0400165 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "EndTag",
Bob Moore08978312005-10-21 00:00:00 -0400166 NULL}
167};
168
169struct 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),
Bob Mooreb229cf92006-04-21 17:15:00 -0400173 "Write Protect", acpi_gbl_rw_decode},
Bob Moore08978312005-10-21 00:00:00 -0400174 {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
184struct 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),
Bob Mooreb229cf92006-04-21 17:15:00 -0400188 "Write Protect", acpi_gbl_rw_decode},
Bob Moore08978312005-10-21 00:00:00 -0400189 {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
199struct 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),
Bob Mooreb229cf92006-04-21 17:15:00 -0400203 "Write Protect", acpi_gbl_rw_decode},
Bob Moore08978312005-10-21 00:00:00 -0400204 {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
210struct 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
227struct 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
244struct 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
261struct 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
279struct 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),
Bob Mooreb229cf92006-04-21 17:15:00 -0400285 "Triggering", acpi_gbl_he_decode},
Bob Moore08978312005-10-21 00:00:00 -0400286 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
Bob Mooreb229cf92006-04-21 17:15:00 -0400287 acpi_gbl_ll_decode},
Bob Moore08978312005-10-21 00:00:00 -0400288 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
Bob Mooreb229cf92006-04-21 17:15:00 -0400289 acpi_gbl_shr_decode},
Bob Moore08978312005-10-21 00:00:00 -0400290 {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
298struct 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 */
315static 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",
Bob Mooreb229cf92006-04-21 17:15:00 -0400321 acpi_gbl_dec_decode},
Bob Moore08978312005-10-21 00:00:00 -0400322 {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
328static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
329 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags),
Bob Moore96db2552005-11-02 00:00:00 -0500330 "Resource Type", (void *)"Memory Range"},
Bob Moore08978312005-10-21 00:00:00 -0400331 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
Bob Mooreb229cf92006-04-21 17:15:00 -0400332 "Write Protect", acpi_gbl_rw_decode},
Bob Moore08978312005-10-21 00:00:00 -0400333 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
Bob Mooreb229cf92006-04-21 17:15:00 -0400334 "Caching", acpi_gbl_mem_decode},
Bob Moore08978312005-10-21 00:00:00 -0400335 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
Bob Mooreb229cf92006-04-21 17:15:00 -0400336 "Range Type", acpi_gbl_mtp_decode},
Bob Moore08978312005-10-21 00:00:00 -0400337 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
Bob Mooreb229cf92006-04-21 17:15:00 -0400338 "Translation", acpi_gbl_ttp_decode}
Bob Moore08978312005-10-21 00:00:00 -0400339};
340
341static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
342 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags),
Bob Moore96db2552005-11-02 00:00:00 -0500343 "Resource Type", (void *)"I/O Range"},
Bob Moore08978312005-10-21 00:00:00 -0400344 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
Bob Mooreb229cf92006-04-21 17:15:00 -0400345 "Range Type", acpi_gbl_rng_decode},
Bob Moore08978312005-10-21 00:00:00 -0400346 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
Bob Mooreb229cf92006-04-21 17:15:00 -0400347 "Translation", acpi_gbl_ttp_decode},
Bob Moore08978312005-10-21 00:00:00 -0400348 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
Bob Mooreb229cf92006-04-21 17:15:00 -0400349 "Translation Type", acpi_gbl_trs_decode}
Bob Moore08978312005-10-21 00:00:00 -0400350};
351
352/*
353 * Table used to dump _PRT contents
354 */
355static 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
375static void
376acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
377{
Bob Moore96db2552005-11-02 00:00:00 -0500378 u8 *target = NULL;
379 u8 *previous_target;
Bob Moore08978312005-10-21 00:00:00 -0400380 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;
Bob Moorec51a4de2005-11-17 13:07:00 -0500389 target = ACPI_ADD_PTR(u8, resource, table->offset);
Bob Moore08978312005-10-21 00:00:00 -0400390 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:
Bob Moore96db2552005-11-02 00:00:00 -0500405 acpi_rs_out_string(name,
406 ACPI_CAST_PTR(char, table->pointer));
Bob Moore08978312005-10-21 00:00:00 -0400407 break;
408
409 case ACPI_RSD_STRING:
Bob Moore96db2552005-11-02 00:00:00 -0500410 acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
Bob Moore08978312005-10-21 00:00:00 -0400411 break;
412
413 /* Data items, 8/16/32/64 bit */
414
415 case ACPI_RSD_UINT8:
Bob Moorec51a4de2005-11-17 13:07:00 -0500416 acpi_rs_out_integer8(name, ACPI_GET8(target));
Bob Moore08978312005-10-21 00:00:00 -0400417 break;
418
419 case ACPI_RSD_UINT16:
Bob Moorec51a4de2005-11-17 13:07:00 -0500420 acpi_rs_out_integer16(name, ACPI_GET16(target));
Bob Moore08978312005-10-21 00:00:00 -0400421 break;
422
423 case ACPI_RSD_UINT32:
Bob Moorec51a4de2005-11-17 13:07:00 -0500424 acpi_rs_out_integer32(name, ACPI_GET32(target));
Bob Moore08978312005-10-21 00:00:00 -0400425 break;
426
427 case ACPI_RSD_UINT64:
Bob Moorec51a4de2005-11-17 13:07:00 -0500428 acpi_rs_out_integer64(name, ACPI_GET64(target));
Bob Moore08978312005-10-21 00:00:00 -0400429 break;
430
431 /* Flags: 1-bit and 2-bit flags supported */
432
433 case ACPI_RSD_1BITFLAG:
Bob Moore96db2552005-11-02 00:00:00 -0500434 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
435 table->
436 pointer[*target &
437 0x01]));
Bob Moore08978312005-10-21 00:00:00 -0400438 break;
439
440 case ACPI_RSD_2BITFLAG:
Bob Moore96db2552005-11-02 00:00:00 -0500441 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
442 table->
443 pointer[*target &
444 0x03]));
Bob Moore08978312005-10-21 00:00:00 -0400445 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);
Bob Moore96db2552005-11-02 00:00:00 -0500454 acpi_rs_dump_short_byte_list(*previous_target,
455 target);
Bob Moore08978312005-10-21 00:00:00 -0400456 }
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) {
Bob Moorec51a4de2005-11-17 13:07:00 -0500465 acpi_rs_dump_byte_list(ACPI_GET16
466 (previous_target),
Bob Moore96db2552005-11-02 00:00:00 -0500467 target);
Bob Moore08978312005-10-21 00:00:00 -0400468 }
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) {
Bob Moore96db2552005-11-02 00:00:00 -0500477 acpi_rs_dump_dword_list(*previous_target,
478 ACPI_CAST_PTR(u32,
479 target));
Bob Moore08978312005-10-21 00:00:00 -0400480 }
481 break;
482
483 case ACPI_RSD_ADDRESS:
484 /*
485 * Common flags for all Address resources
486 */
Bob Moore96db2552005-11-02 00:00:00 -0500487 acpi_rs_dump_address_common(ACPI_CAST_PTR
488 (union acpi_resource_data,
489 target));
Bob Moore08978312005-10-21 00:00:00 -0400490 break;
491
492 case ACPI_RSD_SOURCE:
493 /*
494 * Optional resource_source for Address resources
495 */
Len Brownfd350942007-05-09 23:34:35 -0400496 acpi_rs_dump_resource_source(ACPI_CAST_PTR(struct
497 acpi_resource_source,
498 target));
Bob Moore08978312005-10-21 00:00:00 -0400499 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
525static void
526acpi_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
554static 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
600void 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 =
Bob Moorec51a4de2005-11-17 13:07:00 -0500636 ACPI_ADD_PTR(struct acpi_resource, resource_list,
Bob Moore08978312005-10-21 00:00:00 -0400637 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
656void 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
Bob Moorec51a4de2005-11-17 13:07:00 -0500677 prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
678 prt_element, prt_element->length);
Bob Moore08978312005-10-21 00:00:00 -0400679 }
680}
681
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682/*******************************************************************************
683 *
Robert Moorebda663d2005-09-16 16:51:15 -0400684 * FUNCTION: acpi_rs_out*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 *
Robert Moorebda663d2005-09-16 16:51:15 -0400686 * PARAMETERS: Title - Name of the resource field
687 * Value - Value of the resource field
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 *
689 * RETURN: None
690 *
Robert Moorebda663d2005-09-16 16:51:15 -0400691 * DESCRIPTION: Miscellaneous helper functions to consistently format the
692 * output of the resource dump routines
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 *
694 ******************************************************************************/
695
Robert Moorebda663d2005-09-16 16:51:15 -0400696static void acpi_rs_out_string(char *title, char *value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697{
Bob Mooreb8e4d892006-01-27 16:43:00 -0500698 acpi_os_printf("%27s : %s", title, value);
699 if (!*value) {
700 acpi_os_printf("[NULL NAMESTRING]");
701 }
702 acpi_os_printf("\n");
Robert Moorebda663d2005-09-16 16:51:15 -0400703}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704
Robert Moorebda663d2005-09-16 16:51:15 -0400705static void acpi_rs_out_integer8(char *title, u8 value)
706{
Bob Moore50eca3e2005-09-30 19:03:00 -0400707 acpi_os_printf("%27s : %2.2X\n", title, value);
Robert Moorebda663d2005-09-16 16:51:15 -0400708}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709
Robert Moorebda663d2005-09-16 16:51:15 -0400710static void acpi_rs_out_integer16(char *title, u16 value)
711{
Bob Moore50eca3e2005-09-30 19:03:00 -0400712 acpi_os_printf("%27s : %4.4X\n", title, value);
Robert Moorebda663d2005-09-16 16:51:15 -0400713}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714
Robert Moorebda663d2005-09-16 16:51:15 -0400715static void acpi_rs_out_integer32(char *title, u32 value)
716{
Bob Moore50eca3e2005-09-30 19:03:00 -0400717 acpi_os_printf("%27s : %8.8X\n", title, value);
Robert Moorebda663d2005-09-16 16:51:15 -0400718}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719
Robert Moorebda663d2005-09-16 16:51:15 -0400720static void acpi_rs_out_integer64(char *title, u64 value)
721{
Bob Moore50eca3e2005-09-30 19:03:00 -0400722 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
Robert Moorebda663d2005-09-16 16:51:15 -0400723}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724
Robert Moorebda663d2005-09-16 16:51:15 -0400725static void acpi_rs_out_title(char *title)
726{
Bob Moore50eca3e2005-09-30 19:03:00 -0400727 acpi_os_printf("%27s : ", title);
Robert Moorebda663d2005-09-16 16:51:15 -0400728}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729
Robert Moorebda663d2005-09-16 16:51:15 -0400730/*******************************************************************************
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 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742
Bob Moore08978312005-10-21 00:00:00 -0400743static void acpi_rs_dump_byte_list(u16 length, u8 * data)
Robert Moorebda663d2005-09-16 16:51:15 -0400744{
Bob Moore08978312005-10-21 00:00:00 -0400745 u8 i;
Robert Moorebda663d2005-09-16 16:51:15 -0400746
747 for (i = 0; i < length; i++) {
Bob Moore50eca3e2005-09-30 19:03:00 -0400748 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
Robert Moorebda663d2005-09-16 16:51:15 -0400749 }
750}
751
Bob Moore08978312005-10-21 00:00:00 -0400752static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
Robert Moorebda663d2005-09-16 16:51:15 -0400753{
Bob Moore08978312005-10-21 00:00:00 -0400754 u8 i;
Robert Moorebda663d2005-09-16 16:51:15 -0400755
756 for (i = 0; i < length; i++) {
757 acpi_os_printf("%X ", data[i]);
758 }
759 acpi_os_printf("\n");
760}
761
Bob Moore08978312005-10-21 00:00:00 -0400762static void acpi_rs_dump_dword_list(u8 length, u32 * data)
Bob Moore50eca3e2005-09-30 19:03:00 -0400763{
Bob Moore08978312005-10-21 00:00:00 -0400764 u8 i;
Bob Moore50eca3e2005-09-30 19:03:00 -0400765
Bob Moore08978312005-10-21 00:00:00 -0400766 for (i = 0; i < length; i++) {
767 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
Robert Moorebda663d2005-09-16 16:51:15 -0400768 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769}
770
771#endif