1 /*******************************************************************************
3 * Module Name: rsdump - Functions to display the resource structures.
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #include <acpi/acpi.h>
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);
54 static void acpi_rs_out_integer8(char *title, u8 value);
56 static void acpi_rs_out_integer16(char *title, u16 value);
58 static void acpi_rs_out_integer32(char *title, u32 value);
60 static void acpi_rs_out_integer64(char *title, u64 value);
62 static void acpi_rs_out_title(char *title);
64 static void acpi_rs_dump_byte_list(u16 length, u8 *data);
66 static void acpi_rs_dump_word_list(u16 length, u16 *data);
68 static void acpi_rs_dump_dword_list(u8 length, u32 *data);
70 static void acpi_rs_dump_short_byte_list(u8 length, u8 *data);
73 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
75 static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
78 acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
80 /*******************************************************************************
82 * FUNCTION: acpi_rs_dump_descriptor
84 * PARAMETERS: resource - Buffer containing the resource
85 * table - Table entry to decode the resource
89 * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
91 ******************************************************************************/
94 acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
101 /* First table entry must contain the table length (# of table entries) */
103 count = table->offset;
106 previous_target = target;
107 target = ACPI_ADD_PTR(u8, resource, table->offset);
110 switch (table->opcode) {
113 * Optional resource title
116 acpi_os_printf("%s Resource\n", name);
122 case ACPI_RSD_LITERAL:
123 acpi_rs_out_string(name,
124 ACPI_CAST_PTR(char, table->pointer));
127 case ACPI_RSD_STRING:
128 acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
131 /* Data items, 8/16/32/64 bit */
134 if (table->pointer) {
135 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
140 acpi_rs_out_integer8(name, ACPI_GET8(target));
144 case ACPI_RSD_UINT16:
145 acpi_rs_out_integer16(name, ACPI_GET16(target));
148 case ACPI_RSD_UINT32:
149 acpi_rs_out_integer32(name, ACPI_GET32(target));
152 case ACPI_RSD_UINT64:
153 acpi_rs_out_integer64(name, ACPI_GET64(target));
156 /* Flags: 1-bit and 2-bit flags supported */
158 case ACPI_RSD_1BITFLAG:
159 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
165 case ACPI_RSD_2BITFLAG:
166 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
172 case ACPI_RSD_3BITFLAG:
173 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
179 case ACPI_RSD_SHORTLIST:
181 * Short byte list (single line output) for DMA and IRQ resources
182 * Note: The list length is obtained from the previous table entry
184 if (previous_target) {
185 acpi_rs_out_title(name);
186 acpi_rs_dump_short_byte_list(*previous_target,
191 case ACPI_RSD_SHORTLISTX:
193 * Short byte list (single line output) for GPIO vendor data
194 * Note: The list length is obtained from the previous table entry
196 if (previous_target) {
197 acpi_rs_out_title(name);
198 acpi_rs_dump_short_byte_list(*previous_target,
200 (ACPI_CAST_INDIRECT_PTR
205 case ACPI_RSD_LONGLIST:
207 * Long byte list for Vendor resource data
208 * Note: The list length is obtained from the previous table entry
210 if (previous_target) {
211 acpi_rs_dump_byte_list(ACPI_GET16
217 case ACPI_RSD_DWORDLIST:
219 * Dword list for Extended Interrupt resources
220 * Note: The list length is obtained from the previous table entry
222 if (previous_target) {
223 acpi_rs_dump_dword_list(*previous_target,
229 case ACPI_RSD_WORDLIST:
231 * Word list for GPIO Pin Table
232 * Note: The list length is obtained from the previous table entry
234 if (previous_target) {
235 acpi_rs_dump_word_list(*previous_target,
236 *(ACPI_CAST_INDIRECT_PTR
241 case ACPI_RSD_ADDRESS:
243 * Common flags for all Address resources
245 acpi_rs_dump_address_common(ACPI_CAST_PTR
246 (union acpi_resource_data,
250 case ACPI_RSD_SOURCE:
252 * Optional resource_source for Address resources
254 acpi_rs_dump_resource_source(ACPI_CAST_PTR
256 acpi_resource_source,
261 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
271 /*******************************************************************************
273 * FUNCTION: acpi_rs_dump_resource_source
275 * PARAMETERS: resource_source - Pointer to a Resource Source struct
279 * DESCRIPTION: Common routine for dumping the optional resource_source and the
280 * corresponding resource_source_index.
282 ******************************************************************************/
285 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
287 ACPI_FUNCTION_ENTRY();
289 if (resource_source->index == 0xFF) {
293 acpi_rs_out_integer8("Resource Source Index", resource_source->index);
295 acpi_rs_out_string("Resource Source",
296 resource_source->string_ptr ?
297 resource_source->string_ptr : "[Not Specified]");
300 /*******************************************************************************
302 * FUNCTION: acpi_rs_dump_address_common
304 * PARAMETERS: resource - Pointer to an internal resource descriptor
308 * DESCRIPTION: Dump the fields that are common to all Address resource
311 ******************************************************************************/
313 static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
315 ACPI_FUNCTION_ENTRY();
317 /* Decode the type-specific flags */
319 switch (resource->address.resource_type) {
320 case ACPI_MEMORY_RANGE:
322 acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags);
327 acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags);
330 case ACPI_BUS_NUMBER_RANGE:
332 acpi_rs_out_string("Resource Type", "Bus Number Range");
337 acpi_rs_out_integer8("Resource Type",
338 (u8) resource->address.resource_type);
342 /* Decode the general flags */
344 acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags);
347 /*******************************************************************************
349 * FUNCTION: acpi_rs_dump_resource_list
351 * PARAMETERS: resource_list - Pointer to a resource descriptor list
355 * DESCRIPTION: Dispatches the structure to the correct dump routine.
357 ******************************************************************************/
359 void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
364 ACPI_FUNCTION_ENTRY();
366 /* Check if debug output enabled */
368 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
372 /* Walk list and dump all resource descriptors (END_TAG terminates) */
375 acpi_os_printf("\n[%02X] ", count);
378 /* Validate Type before dispatch */
380 type = resource_list->type;
381 if (type > ACPI_RESOURCE_TYPE_MAX) {
383 ("Invalid descriptor type (%X) in resource list\n",
384 resource_list->type);
388 /* Dump the resource descriptor */
390 if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
391 acpi_rs_dump_descriptor(&resource_list->data,
392 acpi_gbl_dump_serial_bus_dispatch
393 [resource_list->data.
394 common_serial_bus.type]);
396 acpi_rs_dump_descriptor(&resource_list->data,
397 acpi_gbl_dump_resource_dispatch
401 /* Point to the next resource structure */
403 resource_list = ACPI_NEXT_RESOURCE(resource_list);
405 /* Exit when END_TAG descriptor is reached */
407 } while (type != ACPI_RESOURCE_TYPE_END_TAG);
410 /*******************************************************************************
412 * FUNCTION: acpi_rs_dump_irq_list
414 * PARAMETERS: route_table - Pointer to the routing table to dump.
418 * DESCRIPTION: Print IRQ routing table
420 ******************************************************************************/
422 void acpi_rs_dump_irq_list(u8 * route_table)
424 struct acpi_pci_routing_table *prt_element;
427 ACPI_FUNCTION_ENTRY();
429 /* Check if debug output enabled */
431 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
435 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table);
437 /* Dump all table elements, Exit on zero length element */
439 for (count = 0; prt_element->length; count++) {
440 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
442 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
444 prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
445 prt_element, prt_element->length);
449 /*******************************************************************************
451 * FUNCTION: acpi_rs_out*
453 * PARAMETERS: title - Name of the resource field
454 * value - Value of the resource field
458 * DESCRIPTION: Miscellaneous helper functions to consistently format the
459 * output of the resource dump routines
461 ******************************************************************************/
463 static void acpi_rs_out_string(char *title, char *value)
465 acpi_os_printf("%27s : %s", title, value);
467 acpi_os_printf("[NULL NAMESTRING]");
469 acpi_os_printf("\n");
472 static void acpi_rs_out_integer8(char *title, u8 value)
474 acpi_os_printf("%27s : %2.2X\n", title, value);
477 static void acpi_rs_out_integer16(char *title, u16 value)
479 acpi_os_printf("%27s : %4.4X\n", title, value);
482 static void acpi_rs_out_integer32(char *title, u32 value)
484 acpi_os_printf("%27s : %8.8X\n", title, value);
487 static void acpi_rs_out_integer64(char *title, u64 value)
489 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
492 static void acpi_rs_out_title(char *title)
494 acpi_os_printf("%27s : ", title);
497 /*******************************************************************************
499 * FUNCTION: acpi_rs_dump*List
501 * PARAMETERS: length - Number of elements in the list
502 * data - Start of the list
506 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
508 ******************************************************************************/
510 static void acpi_rs_dump_byte_list(u16 length, u8 * data)
514 for (i = 0; i < length; i++) {
515 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
519 static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
523 for (i = 0; i < length; i++) {
524 acpi_os_printf("%X ", data[i]);
526 acpi_os_printf("\n");
529 static void acpi_rs_dump_dword_list(u8 length, u32 * data)
533 for (i = 0; i < length; i++) {
534 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
538 static void acpi_rs_dump_word_list(u16 length, u16 *data)
542 for (i = 0; i < length; i++) {
543 acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i, data[i]);