1 /*******************************************************************************
2 *
3 * Module Name: rsdump - Functions to display the resource structures.
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2012, 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_word_list(u16 length, u16 *data);
67
68 static void acpi_rs_dump_dword_list(u8 length, u32 *data);
69
70 static void acpi_rs_dump_short_byte_list(u8 length, u8 *data);
71
72 static void
73 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
74
75 static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
76
77 static void
78 acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
79
80 #define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f)
81 #define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
82 #define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info))
83
84 /*******************************************************************************
85 *
86 * Resource Descriptor info tables
87 *
88 * Note: The first table entry must be a Title or Literal and must contain
89 * the table length (number of table entries)
90 *
91 ******************************************************************************/
92
93 struct acpi_rsdump_info acpi_rs_dump_irq[7] = {
94 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
95 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.descriptor_length),
96 "Descriptor Length", NULL},
97 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
98 acpi_gbl_he_decode},
99 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
100 acpi_gbl_ll_decode},
101 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
102 acpi_gbl_shr_decode},
103 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count),
104 "Interrupt Count", NULL},
105 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]),
106 "Interrupt List", NULL}
107 };
108
109 struct acpi_rsdump_info acpi_rs_dump_dma[6] = {
110 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL},
111 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed",
112 acpi_gbl_typ_decode},
113 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
114 acpi_gbl_bm_decode},
115 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
116 acpi_gbl_siz_decode},
117 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count",
118 NULL},
119 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List",
120 NULL}
121 };
122
123 struct acpi_rsdump_info acpi_rs_dump_start_dpf[4] = {
124 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
125 "Start-Dependent-Functions", NULL},
126 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(start_dpf.descriptor_length),
127 "Descriptor Length", NULL},
128 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority),
129 "Compatibility Priority", acpi_gbl_config_decode},
130 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness),
131 "Performance/Robustness", acpi_gbl_config_decode}
132 };
133
134 struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = {
135 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf),
136 "End-Dependent-Functions", NULL}
137 };
138
139 struct acpi_rsdump_info acpi_rs_dump_io[6] = {
140 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL},
141 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding",
142 acpi_gbl_io_decode},
143 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL},
144 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL},
145 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL},
146 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length",
147 NULL}
148 };
149
150 struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = {
151 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io),
152 "Fixed I/O", NULL},
153 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL},
154 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length),
155 "Address Length", NULL}
156 };
157
158 struct acpi_rsdump_info acpi_rs_dump_vendor[3] = {
159 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor),
160 "Vendor Specific", NULL},
161 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL},
162 {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data",
163 NULL}
164 };
165
166 struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = {
167 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "EndTag",
168 NULL}
169 };
170
171 struct acpi_rsdump_info acpi_rs_dump_memory24[6] = {
172 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24),
173 "24-Bit Memory Range", NULL},
174 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect),
175 "Write Protect", acpi_gbl_rw_decode},
176 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum",
177 NULL},
178 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum",
179 NULL},
180 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment",
181 NULL},
182 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length),
183 "Address Length", NULL}
184 };
185
186 struct acpi_rsdump_info acpi_rs_dump_memory32[6] = {
187 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32),
188 "32-Bit Memory Range", NULL},
189 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect),
190 "Write Protect", acpi_gbl_rw_decode},
191 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum",
192 NULL},
193 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum",
194 NULL},
195 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment",
196 NULL},
197 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length),
198 "Address Length", NULL}
199 };
200
201 struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = {
202 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32),
203 "32-Bit Fixed Memory Range", NULL},
204 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect),
205 "Write Protect", acpi_gbl_rw_decode},
206 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address",
207 NULL},
208 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length),
209 "Address Length", NULL}
210 };
211
212 struct acpi_rsdump_info acpi_rs_dump_address16[8] = {
213 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16),
214 "16-Bit WORD Address Space", NULL},
215 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
216 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity",
217 NULL},
218 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum",
219 NULL},
220 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum",
221 NULL},
222 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset),
223 "Translation Offset", NULL},
224 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length),
225 "Address Length", NULL},
226 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL}
227 };
228
229 struct acpi_rsdump_info acpi_rs_dump_address32[8] = {
230 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32),
231 "32-Bit DWORD Address Space", NULL},
232 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
233 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity",
234 NULL},
235 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum",
236 NULL},
237 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum",
238 NULL},
239 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset),
240 "Translation Offset", NULL},
241 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length),
242 "Address Length", NULL},
243 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL}
244 };
245
246 struct acpi_rsdump_info acpi_rs_dump_address64[8] = {
247 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64),
248 "64-Bit QWORD Address Space", NULL},
249 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
250 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity",
251 NULL},
252 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum",
253 NULL},
254 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum",
255 NULL},
256 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset),
257 "Translation Offset", NULL},
258 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length),
259 "Address Length", NULL},
260 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL}
261 };
262
263 struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = {
264 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64),
265 "64-Bit Extended Address Space", NULL},
266 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
267 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity),
268 "Granularity", NULL},
269 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum),
270 "Address Minimum", NULL},
271 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum),
272 "Address Maximum", NULL},
273 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset),
274 "Translation Offset", NULL},
275 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length),
276 "Address Length", NULL},
277 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific),
278 "Type-Specific Attribute", NULL}
279 };
280
281 struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = {
282 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq),
283 "Extended IRQ", NULL},
284 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer),
285 "Type", acpi_gbl_consume_decode},
286 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering),
287 "Triggering", acpi_gbl_he_decode},
288 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
289 acpi_gbl_ll_decode},
290 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
291 acpi_gbl_shr_decode},
292 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL,
293 NULL},
294 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count),
295 "Interrupt Count", NULL},
296 {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]),
297 "Interrupt List", NULL}
298 };
299
300 struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = {
301 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg),
302 "Generic Register", NULL},
303 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID",
304 NULL},
305 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width",
306 NULL},
307 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset",
308 NULL},
309 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size),
310 "Access Size", NULL},
311 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL}
312 };
313
314 struct acpi_rsdump_info acpi_rs_dump_gpio[16] = {
315 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_gpio), "GPIO", NULL},
316 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.revision_id), "RevisionId", NULL},
317 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.connection_type),
318 "ConnectionType", acpi_gbl_ct_decode},
319 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.producer_consumer),
320 "ProducerConsumer", acpi_gbl_consume_decode},
321 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.pin_config), "PinConfig",
322 acpi_gbl_ppc_decode},
323 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.sharable), "Sharable",
324 acpi_gbl_shr_decode},
325 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.io_restriction),
326 "IoRestriction", acpi_gbl_ior_decode},
327 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.triggering), "Triggering",
328 acpi_gbl_he_decode},
329 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.polarity), "Polarity",
330 acpi_gbl_ll_decode},
331 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.drive_strength), "DriveStrength",
332 NULL},
333 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.debounce_timeout),
334 "DebounceTimeout", NULL},
335 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(gpio.resource_source),
336 "ResourceSource", NULL},
337 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.pin_table_length),
338 "PinTableLength", NULL},
339 {ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET(gpio.pin_table), "PinTable", NULL},
340 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.vendor_length), "VendorLength",
341 NULL},
342 {ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(gpio.vendor_data), "VendorData",
343 NULL},
344 };
345
346 struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = {
347 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_dma),
348 "FixedDma", NULL},
349 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.request_lines),
350 "RequestLines", NULL},
351 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.channels), "Channels",
352 NULL},
353 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_dma.width), "TransferWidth",
354 acpi_gbl_dts_decode},
355 };
356
357 #define ACPI_RS_DUMP_COMMON_SERIAL_BUS \
358 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.revision_id), "RevisionId", NULL}, \
359 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \
360 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \
361 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \
362 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \
363 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \
364 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \
365 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \
366 {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL},
367
368 struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = {
369 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus),
370 "Common Serial Bus", NULL},
371 ACPI_RS_DUMP_COMMON_SERIAL_BUS
372 };
373
374 struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = {
375 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus),
376 "I2C Serial Bus", NULL},
377 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
378 ACPI_RSD_OFFSET(i2c_serial_bus.
379 access_mode),
380 "AccessMode", acpi_gbl_am_decode},
381 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(i2c_serial_bus.connection_speed),
382 "ConnectionSpeed", NULL},
383 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(i2c_serial_bus.slave_address),
384 "SlaveAddress", NULL},
385 };
386
387 struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = {
388 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus),
389 "Spi Serial Bus", NULL},
390 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
391 ACPI_RSD_OFFSET(spi_serial_bus.
392 wire_mode), "WireMode",
393 acpi_gbl_wm_decode},
394 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(spi_serial_bus.device_polarity),
395 "DevicePolarity", acpi_gbl_dp_decode},
396 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.data_bit_length),
397 "DataBitLength", NULL},
398 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_phase),
399 "ClockPhase", acpi_gbl_cph_decode},
400 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_polarity),
401 "ClockPolarity", acpi_gbl_cpo_decode},
402 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(spi_serial_bus.device_selection),
403 "DeviceSelection", NULL},
404 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(spi_serial_bus.connection_speed),
405 "ConnectionSpeed", NULL},
406 };
407
408 struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = {
409 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus),
410 "Uart Serial Bus", NULL},
411 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG,
412 ACPI_RSD_OFFSET(uart_serial_bus.
413 flow_control),
414 "FlowControl", acpi_gbl_fc_decode},
415 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.stop_bits),
416 "StopBits", acpi_gbl_sb_decode},
417 {ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.data_bits),
418 "DataBits", acpi_gbl_bpb_decode},
419 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.endian), "Endian",
420 acpi_gbl_ed_decode},
421 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.parity), "Parity",
422 acpi_gbl_pt_decode},
423 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.lines_enabled),
424 "LinesEnabled", NULL},
425 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.rx_fifo_size),
426 "RxFifoSize", NULL},
427 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.tx_fifo_size),
428 "TxFifoSize", NULL},
429 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(uart_serial_bus.default_baud_rate),
430 "ConnectionSpeed", NULL},
431 };
432
433 /*
434 * Tables used for common address descriptor flag fields
435 */
436 static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = {
437 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL,
438 NULL},
439 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer),
440 "Consumer/Producer", acpi_gbl_consume_decode},
441 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode",
442 acpi_gbl_dec_decode},
443 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed),
444 "Min Relocatability", acpi_gbl_min_decode},
445 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed),
446 "Max Relocatability", acpi_gbl_max_decode}
447 };
448
449 static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
450 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags),
451 "Resource Type", (void *)"Memory Range"},
452 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
453 "Write Protect", acpi_gbl_rw_decode},
454 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
455 "Caching", acpi_gbl_mem_decode},
456 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
457 "Range Type", acpi_gbl_mtp_decode},
458 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
459 "Translation", acpi_gbl_ttp_decode}
460 };
461
462 static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
463 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags),
464 "Resource Type", (void *)"I/O Range"},
465 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
466 "Range Type", acpi_gbl_rng_decode},
467 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
468 "Translation", acpi_gbl_ttp_decode},
469 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
470 "Translation Type", acpi_gbl_trs_decode}
471 };
472
473 /*
474 * Table used to dump _PRT contents
475 */
476 static struct acpi_rsdump_info acpi_rs_dump_prt[5] = {
477 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL},
478 {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL},
479 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL},
480 {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL},
481 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL}
482 };
483
484 /*******************************************************************************
485 *
486 * FUNCTION: acpi_rs_dump_descriptor
487 *
488 * PARAMETERS: Resource
489 *
490 * RETURN: None
491 *
492 * DESCRIPTION:
493 *
494 ******************************************************************************/
495
496 static void
acpi_rs_dump_descriptor(void * resource,struct acpi_rsdump_info * table)497 acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
498 {
499 u8 *target = NULL;
500 u8 *previous_target;
501 char *name;
502 u8 count;
503
504 /* First table entry must contain the table length (# of table entries) */
505
506 count = table->offset;
507
508 while (count) {
509 previous_target = target;
510 target = ACPI_ADD_PTR(u8, resource, table->offset);
511 name = table->name;
512
513 switch (table->opcode) {
514 case ACPI_RSD_TITLE:
515 /*
516 * Optional resource title
517 */
518 if (table->name) {
519 acpi_os_printf("%s Resource\n", name);
520 }
521 break;
522
523 /* Strings */
524
525 case ACPI_RSD_LITERAL:
526 acpi_rs_out_string(name,
527 ACPI_CAST_PTR(char, table->pointer));
528 break;
529
530 case ACPI_RSD_STRING:
531 acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
532 break;
533
534 /* Data items, 8/16/32/64 bit */
535
536 case ACPI_RSD_UINT8:
537 if (table->pointer) {
538 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
539 table->
540 pointer
541 [*target]));
542 } else {
543 acpi_rs_out_integer8(name, ACPI_GET8(target));
544 }
545 break;
546
547 case ACPI_RSD_UINT16:
548 acpi_rs_out_integer16(name, ACPI_GET16(target));
549 break;
550
551 case ACPI_RSD_UINT32:
552 acpi_rs_out_integer32(name, ACPI_GET32(target));
553 break;
554
555 case ACPI_RSD_UINT64:
556 acpi_rs_out_integer64(name, ACPI_GET64(target));
557 break;
558
559 /* Flags: 1-bit and 2-bit flags supported */
560
561 case ACPI_RSD_1BITFLAG:
562 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
563 table->
564 pointer[*target &
565 0x01]));
566 break;
567
568 case ACPI_RSD_2BITFLAG:
569 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
570 table->
571 pointer[*target &
572 0x03]));
573 break;
574
575 case ACPI_RSD_3BITFLAG:
576 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
577 table->
578 pointer[*target &
579 0x07]));
580 break;
581
582 case ACPI_RSD_SHORTLIST:
583 /*
584 * Short byte list (single line output) for DMA and IRQ resources
585 * Note: The list length is obtained from the previous table entry
586 */
587 if (previous_target) {
588 acpi_rs_out_title(name);
589 acpi_rs_dump_short_byte_list(*previous_target,
590 target);
591 }
592 break;
593
594 case ACPI_RSD_SHORTLISTX:
595 /*
596 * Short byte list (single line output) for GPIO vendor data
597 * Note: The list length is obtained from the previous table entry
598 */
599 if (previous_target) {
600 acpi_rs_out_title(name);
601 acpi_rs_dump_short_byte_list(*previous_target,
602 *
603 (ACPI_CAST_INDIRECT_PTR
604 (u8, target)));
605 }
606 break;
607
608 case ACPI_RSD_LONGLIST:
609 /*
610 * Long byte list for Vendor resource data
611 * Note: The list length is obtained from the previous table entry
612 */
613 if (previous_target) {
614 acpi_rs_dump_byte_list(ACPI_GET16
615 (previous_target),
616 target);
617 }
618 break;
619
620 case ACPI_RSD_DWORDLIST:
621 /*
622 * Dword list for Extended Interrupt resources
623 * Note: The list length is obtained from the previous table entry
624 */
625 if (previous_target) {
626 acpi_rs_dump_dword_list(*previous_target,
627 ACPI_CAST_PTR(u32,
628 target));
629 }
630 break;
631
632 case ACPI_RSD_WORDLIST:
633 /*
634 * Word list for GPIO Pin Table
635 * Note: The list length is obtained from the previous table entry
636 */
637 if (previous_target) {
638 acpi_rs_dump_word_list(*previous_target,
639 *(ACPI_CAST_INDIRECT_PTR
640 (u16, target)));
641 }
642 break;
643
644 case ACPI_RSD_ADDRESS:
645 /*
646 * Common flags for all Address resources
647 */
648 acpi_rs_dump_address_common(ACPI_CAST_PTR
649 (union acpi_resource_data,
650 target));
651 break;
652
653 case ACPI_RSD_SOURCE:
654 /*
655 * Optional resource_source for Address resources
656 */
657 acpi_rs_dump_resource_source(ACPI_CAST_PTR(struct
658 acpi_resource_source,
659 target));
660 break;
661
662 default:
663 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
664 table->opcode);
665 return;
666 }
667
668 table++;
669 count--;
670 }
671 }
672
673 /*******************************************************************************
674 *
675 * FUNCTION: acpi_rs_dump_resource_source
676 *
677 * PARAMETERS: resource_source - Pointer to a Resource Source struct
678 *
679 * RETURN: None
680 *
681 * DESCRIPTION: Common routine for dumping the optional resource_source and the
682 * corresponding resource_source_index.
683 *
684 ******************************************************************************/
685
686 static void
acpi_rs_dump_resource_source(struct acpi_resource_source * resource_source)687 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
688 {
689 ACPI_FUNCTION_ENTRY();
690
691 if (resource_source->index == 0xFF) {
692 return;
693 }
694
695 acpi_rs_out_integer8("Resource Source Index", resource_source->index);
696
697 acpi_rs_out_string("Resource Source",
698 resource_source->string_ptr ?
699 resource_source->string_ptr : "[Not Specified]");
700 }
701
702 /*******************************************************************************
703 *
704 * FUNCTION: acpi_rs_dump_address_common
705 *
706 * PARAMETERS: Resource - Pointer to an internal resource descriptor
707 *
708 * RETURN: None
709 *
710 * DESCRIPTION: Dump the fields that are common to all Address resource
711 * descriptors
712 *
713 ******************************************************************************/
714
acpi_rs_dump_address_common(union acpi_resource_data * resource)715 static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
716 {
717 ACPI_FUNCTION_ENTRY();
718
719 /* Decode the type-specific flags */
720
721 switch (resource->address.resource_type) {
722 case ACPI_MEMORY_RANGE:
723
724 acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags);
725 break;
726
727 case ACPI_IO_RANGE:
728
729 acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags);
730 break;
731
732 case ACPI_BUS_NUMBER_RANGE:
733
734 acpi_rs_out_string("Resource Type", "Bus Number Range");
735 break;
736
737 default:
738
739 acpi_rs_out_integer8("Resource Type",
740 (u8) resource->address.resource_type);
741 break;
742 }
743
744 /* Decode the general flags */
745
746 acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags);
747 }
748
749 /*******************************************************************************
750 *
751 * FUNCTION: acpi_rs_dump_resource_list
752 *
753 * PARAMETERS: resource_list - Pointer to a resource descriptor list
754 *
755 * RETURN: None
756 *
757 * DESCRIPTION: Dispatches the structure to the correct dump routine.
758 *
759 ******************************************************************************/
760
acpi_rs_dump_resource_list(struct acpi_resource * resource_list)761 void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
762 {
763 u32 count = 0;
764 u32 type;
765
766 ACPI_FUNCTION_ENTRY();
767
768 if (!(acpi_dbg_level & ACPI_LV_RESOURCES)
769 || !(_COMPONENT & acpi_dbg_layer)) {
770 return;
771 }
772
773 /* Walk list and dump all resource descriptors (END_TAG terminates) */
774
775 do {
776 acpi_os_printf("\n[%02X] ", count);
777 count++;
778
779 /* Validate Type before dispatch */
780
781 type = resource_list->type;
782 if (type > ACPI_RESOURCE_TYPE_MAX) {
783 acpi_os_printf
784 ("Invalid descriptor type (%X) in resource list\n",
785 resource_list->type);
786 return;
787 }
788
789 /* Dump the resource descriptor */
790
791 if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
792 acpi_rs_dump_descriptor(&resource_list->data,
793 acpi_gbl_dump_serial_bus_dispatch
794 [resource_list->data.
795 common_serial_bus.type]);
796 } else {
797 acpi_rs_dump_descriptor(&resource_list->data,
798 acpi_gbl_dump_resource_dispatch
799 [type]);
800 }
801
802 /* Point to the next resource structure */
803
804 resource_list = ACPI_NEXT_RESOURCE(resource_list);
805
806 /* Exit when END_TAG descriptor is reached */
807
808 } while (type != ACPI_RESOURCE_TYPE_END_TAG);
809 }
810
811 /*******************************************************************************
812 *
813 * FUNCTION: acpi_rs_dump_irq_list
814 *
815 * PARAMETERS: route_table - Pointer to the routing table to dump.
816 *
817 * RETURN: None
818 *
819 * DESCRIPTION: Print IRQ routing table
820 *
821 ******************************************************************************/
822
acpi_rs_dump_irq_list(u8 * route_table)823 void acpi_rs_dump_irq_list(u8 * route_table)
824 {
825 struct acpi_pci_routing_table *prt_element;
826 u8 count;
827
828 ACPI_FUNCTION_ENTRY();
829
830 if (!(acpi_dbg_level & ACPI_LV_RESOURCES)
831 || !(_COMPONENT & acpi_dbg_layer)) {
832 return;
833 }
834
835 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table);
836
837 /* Dump all table elements, Exit on zero length element */
838
839 for (count = 0; prt_element->length; count++) {
840 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
841 count);
842 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
843
844 prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
845 prt_element, prt_element->length);
846 }
847 }
848
849 /*******************************************************************************
850 *
851 * FUNCTION: acpi_rs_out*
852 *
853 * PARAMETERS: Title - Name of the resource field
854 * Value - Value of the resource field
855 *
856 * RETURN: None
857 *
858 * DESCRIPTION: Miscellaneous helper functions to consistently format the
859 * output of the resource dump routines
860 *
861 ******************************************************************************/
862
acpi_rs_out_string(char * title,char * value)863 static void acpi_rs_out_string(char *title, char *value)
864 {
865 acpi_os_printf("%27s : %s", title, value);
866 if (!*value) {
867 acpi_os_printf("[NULL NAMESTRING]");
868 }
869 acpi_os_printf("\n");
870 }
871
acpi_rs_out_integer8(char * title,u8 value)872 static void acpi_rs_out_integer8(char *title, u8 value)
873 {
874 acpi_os_printf("%27s : %2.2X\n", title, value);
875 }
876
acpi_rs_out_integer16(char * title,u16 value)877 static void acpi_rs_out_integer16(char *title, u16 value)
878 {
879 acpi_os_printf("%27s : %4.4X\n", title, value);
880 }
881
acpi_rs_out_integer32(char * title,u32 value)882 static void acpi_rs_out_integer32(char *title, u32 value)
883 {
884 acpi_os_printf("%27s : %8.8X\n", title, value);
885 }
886
acpi_rs_out_integer64(char * title,u64 value)887 static void acpi_rs_out_integer64(char *title, u64 value)
888 {
889 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
890 }
891
acpi_rs_out_title(char * title)892 static void acpi_rs_out_title(char *title)
893 {
894 acpi_os_printf("%27s : ", title);
895 }
896
897 /*******************************************************************************
898 *
899 * FUNCTION: acpi_rs_dump*List
900 *
901 * PARAMETERS: Length - Number of elements in the list
902 * Data - Start of the list
903 *
904 * RETURN: None
905 *
906 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
907 *
908 ******************************************************************************/
909
acpi_rs_dump_byte_list(u16 length,u8 * data)910 static void acpi_rs_dump_byte_list(u16 length, u8 * data)
911 {
912 u8 i;
913
914 for (i = 0; i < length; i++) {
915 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
916 }
917 }
918
acpi_rs_dump_short_byte_list(u8 length,u8 * data)919 static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
920 {
921 u8 i;
922
923 for (i = 0; i < length; i++) {
924 acpi_os_printf("%X ", data[i]);
925 }
926 acpi_os_printf("\n");
927 }
928
acpi_rs_dump_dword_list(u8 length,u32 * data)929 static void acpi_rs_dump_dword_list(u8 length, u32 * data)
930 {
931 u8 i;
932
933 for (i = 0; i < length; i++) {
934 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
935 }
936 }
937
acpi_rs_dump_word_list(u16 length,u16 * data)938 static void acpi_rs_dump_word_list(u16 length, u16 *data)
939 {
940 u16 i;
941
942 for (i = 0; i < length; i++) {
943 acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i, data[i]);
944 }
945 }
946
947 #endif
948