xref: /openbmc/linux/drivers/acpi/acpica/rsdump.c (revision 42f8fb75c43cc67f06424f991009b3af674f93eb)
195b482a8SLen Brown /*******************************************************************************
295b482a8SLen Brown  *
395b482a8SLen Brown  * Module Name: rsdump - Functions to display the resource structures.
495b482a8SLen Brown  *
595b482a8SLen Brown  ******************************************************************************/
695b482a8SLen Brown 
795b482a8SLen Brown /*
877848130SBob Moore  * Copyright (C) 2000 - 2012, Intel Corp.
995b482a8SLen Brown  * All rights reserved.
1095b482a8SLen Brown  *
1195b482a8SLen Brown  * Redistribution and use in source and binary forms, with or without
1295b482a8SLen Brown  * modification, are permitted provided that the following conditions
1395b482a8SLen Brown  * are met:
1495b482a8SLen Brown  * 1. Redistributions of source code must retain the above copyright
1595b482a8SLen Brown  *    notice, this list of conditions, and the following disclaimer,
1695b482a8SLen Brown  *    without modification.
1795b482a8SLen Brown  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1895b482a8SLen Brown  *    substantially similar to the "NO WARRANTY" disclaimer below
1995b482a8SLen Brown  *    ("Disclaimer") and any redistribution must be conditioned upon
2095b482a8SLen Brown  *    including a substantially similar Disclaimer requirement for further
2195b482a8SLen Brown  *    binary redistribution.
2295b482a8SLen Brown  * 3. Neither the names of the above-listed copyright holders nor the names
2395b482a8SLen Brown  *    of any contributors may be used to endorse or promote products derived
2495b482a8SLen Brown  *    from this software without specific prior written permission.
2595b482a8SLen Brown  *
2695b482a8SLen Brown  * Alternatively, this software may be distributed under the terms of the
2795b482a8SLen Brown  * GNU General Public License ("GPL") version 2 as published by the Free
2895b482a8SLen Brown  * Software Foundation.
2995b482a8SLen Brown  *
3095b482a8SLen Brown  * NO WARRANTY
3195b482a8SLen Brown  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3295b482a8SLen Brown  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3395b482a8SLen Brown  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3495b482a8SLen Brown  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3595b482a8SLen Brown  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3695b482a8SLen Brown  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3795b482a8SLen Brown  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3895b482a8SLen Brown  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3995b482a8SLen Brown  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4095b482a8SLen Brown  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4195b482a8SLen Brown  * POSSIBILITY OF SUCH DAMAGES.
4295b482a8SLen Brown  */
4395b482a8SLen Brown 
4495b482a8SLen Brown #include <acpi/acpi.h>
45e2f7a777SLen Brown #include "accommon.h"
46e2f7a777SLen Brown #include "acresrc.h"
4795b482a8SLen Brown 
4895b482a8SLen Brown #define _COMPONENT          ACPI_RESOURCES
4995b482a8SLen Brown ACPI_MODULE_NAME("rsdump")
5095b482a8SLen Brown #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
5195b482a8SLen Brown /* Local prototypes */
5295b482a8SLen Brown static void acpi_rs_out_string(char *title, char *value);
5395b482a8SLen Brown 
5495b482a8SLen Brown static void acpi_rs_out_integer8(char *title, u8 value);
5595b482a8SLen Brown 
5695b482a8SLen Brown static void acpi_rs_out_integer16(char *title, u16 value);
5795b482a8SLen Brown 
5895b482a8SLen Brown static void acpi_rs_out_integer32(char *title, u32 value);
5995b482a8SLen Brown 
6095b482a8SLen Brown static void acpi_rs_out_integer64(char *title, u64 value);
6195b482a8SLen Brown 
6295b482a8SLen Brown static void acpi_rs_out_title(char *title);
6395b482a8SLen Brown 
6495b482a8SLen Brown static void acpi_rs_dump_byte_list(u16 length, u8 *data);
6595b482a8SLen Brown 
66e0fe0a8dSLin Ming static void acpi_rs_dump_word_list(u16 length, u16 *data);
67e0fe0a8dSLin Ming 
6895b482a8SLen Brown static void acpi_rs_dump_dword_list(u8 length, u32 *data);
6995b482a8SLen Brown 
7095b482a8SLen Brown static void acpi_rs_dump_short_byte_list(u8 length, u8 *data);
7195b482a8SLen Brown 
7295b482a8SLen Brown static void
7395b482a8SLen Brown acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
7495b482a8SLen Brown 
7595b482a8SLen Brown static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
7695b482a8SLen Brown 
7795b482a8SLen Brown static void
7895b482a8SLen Brown acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
7995b482a8SLen Brown 
8095b482a8SLen Brown /*******************************************************************************
8195b482a8SLen Brown  *
8295b482a8SLen Brown  * FUNCTION:    acpi_rs_dump_descriptor
8395b482a8SLen Brown  *
84*42f8fb75SBob Moore  * PARAMETERS:  resource            - Buffer containing the resource
85*42f8fb75SBob Moore  *              table               - Table entry to decode the resource
8695b482a8SLen Brown  *
8795b482a8SLen Brown  * RETURN:      None
8895b482a8SLen Brown  *
89*42f8fb75SBob Moore  * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
9095b482a8SLen Brown  *
9195b482a8SLen Brown  ******************************************************************************/
9295b482a8SLen Brown 
9395b482a8SLen Brown static void
9495b482a8SLen Brown acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
9595b482a8SLen Brown {
9695b482a8SLen Brown 	u8 *target = NULL;
9795b482a8SLen Brown 	u8 *previous_target;
9895b482a8SLen Brown 	char *name;
9995b482a8SLen Brown 	u8 count;
10095b482a8SLen Brown 
10195b482a8SLen Brown 	/* First table entry must contain the table length (# of table entries) */
10295b482a8SLen Brown 
10395b482a8SLen Brown 	count = table->offset;
10495b482a8SLen Brown 
10595b482a8SLen Brown 	while (count) {
10695b482a8SLen Brown 		previous_target = target;
10795b482a8SLen Brown 		target = ACPI_ADD_PTR(u8, resource, table->offset);
10895b482a8SLen Brown 		name = table->name;
10995b482a8SLen Brown 
11095b482a8SLen Brown 		switch (table->opcode) {
11195b482a8SLen Brown 		case ACPI_RSD_TITLE:
11295b482a8SLen Brown 			/*
11395b482a8SLen Brown 			 * Optional resource title
11495b482a8SLen Brown 			 */
11595b482a8SLen Brown 			if (table->name) {
11695b482a8SLen Brown 				acpi_os_printf("%s Resource\n", name);
11795b482a8SLen Brown 			}
11895b482a8SLen Brown 			break;
11995b482a8SLen Brown 
12095b482a8SLen Brown 			/* Strings */
12195b482a8SLen Brown 
12295b482a8SLen Brown 		case ACPI_RSD_LITERAL:
12395b482a8SLen Brown 			acpi_rs_out_string(name,
12495b482a8SLen Brown 					   ACPI_CAST_PTR(char, table->pointer));
12595b482a8SLen Brown 			break;
12695b482a8SLen Brown 
12795b482a8SLen Brown 		case ACPI_RSD_STRING:
12895b482a8SLen Brown 			acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
12995b482a8SLen Brown 			break;
13095b482a8SLen Brown 
13195b482a8SLen Brown 			/* Data items, 8/16/32/64 bit */
13295b482a8SLen Brown 
13395b482a8SLen Brown 		case ACPI_RSD_UINT8:
134e0fe0a8dSLin Ming 			if (table->pointer) {
135e0fe0a8dSLin Ming 				acpi_rs_out_string(name, ACPI_CAST_PTR(char,
136e0fe0a8dSLin Ming 								       table->
137e0fe0a8dSLin Ming 								       pointer
138e0fe0a8dSLin Ming 								       [*target]));
139e0fe0a8dSLin Ming 			} else {
14095b482a8SLen Brown 				acpi_rs_out_integer8(name, ACPI_GET8(target));
141e0fe0a8dSLin Ming 			}
14295b482a8SLen Brown 			break;
14395b482a8SLen Brown 
14495b482a8SLen Brown 		case ACPI_RSD_UINT16:
14595b482a8SLen Brown 			acpi_rs_out_integer16(name, ACPI_GET16(target));
14695b482a8SLen Brown 			break;
14795b482a8SLen Brown 
14895b482a8SLen Brown 		case ACPI_RSD_UINT32:
14995b482a8SLen Brown 			acpi_rs_out_integer32(name, ACPI_GET32(target));
15095b482a8SLen Brown 			break;
15195b482a8SLen Brown 
15295b482a8SLen Brown 		case ACPI_RSD_UINT64:
15395b482a8SLen Brown 			acpi_rs_out_integer64(name, ACPI_GET64(target));
15495b482a8SLen Brown 			break;
15595b482a8SLen Brown 
15695b482a8SLen Brown 			/* Flags: 1-bit and 2-bit flags supported */
15795b482a8SLen Brown 
15895b482a8SLen Brown 		case ACPI_RSD_1BITFLAG:
15995b482a8SLen Brown 			acpi_rs_out_string(name, ACPI_CAST_PTR(char,
16095b482a8SLen Brown 							       table->
16195b482a8SLen Brown 							       pointer[*target &
16295b482a8SLen Brown 								       0x01]));
16395b482a8SLen Brown 			break;
16495b482a8SLen Brown 
16595b482a8SLen Brown 		case ACPI_RSD_2BITFLAG:
16695b482a8SLen Brown 			acpi_rs_out_string(name, ACPI_CAST_PTR(char,
16795b482a8SLen Brown 							       table->
16895b482a8SLen Brown 							       pointer[*target &
16995b482a8SLen Brown 								       0x03]));
17095b482a8SLen Brown 			break;
17195b482a8SLen Brown 
172e0fe0a8dSLin Ming 		case ACPI_RSD_3BITFLAG:
173e0fe0a8dSLin Ming 			acpi_rs_out_string(name, ACPI_CAST_PTR(char,
174e0fe0a8dSLin Ming 							       table->
175e0fe0a8dSLin Ming 							       pointer[*target &
176e0fe0a8dSLin Ming 								       0x07]));
177e0fe0a8dSLin Ming 			break;
178e0fe0a8dSLin Ming 
17995b482a8SLen Brown 		case ACPI_RSD_SHORTLIST:
18095b482a8SLen Brown 			/*
18195b482a8SLen Brown 			 * Short byte list (single line output) for DMA and IRQ resources
18295b482a8SLen Brown 			 * Note: The list length is obtained from the previous table entry
18395b482a8SLen Brown 			 */
18495b482a8SLen Brown 			if (previous_target) {
18595b482a8SLen Brown 				acpi_rs_out_title(name);
18695b482a8SLen Brown 				acpi_rs_dump_short_byte_list(*previous_target,
18795b482a8SLen Brown 							     target);
18895b482a8SLen Brown 			}
18995b482a8SLen Brown 			break;
19095b482a8SLen Brown 
191e0fe0a8dSLin Ming 		case ACPI_RSD_SHORTLISTX:
192e0fe0a8dSLin Ming 			/*
193e0fe0a8dSLin Ming 			 * Short byte list (single line output) for GPIO vendor data
194e0fe0a8dSLin Ming 			 * Note: The list length is obtained from the previous table entry
195e0fe0a8dSLin Ming 			 */
196e0fe0a8dSLin Ming 			if (previous_target) {
197e0fe0a8dSLin Ming 				acpi_rs_out_title(name);
198e0fe0a8dSLin Ming 				acpi_rs_dump_short_byte_list(*previous_target,
199e0fe0a8dSLin Ming 							     *
200e0fe0a8dSLin Ming 							     (ACPI_CAST_INDIRECT_PTR
201e0fe0a8dSLin Ming 							      (u8, target)));
202e0fe0a8dSLin Ming 			}
203e0fe0a8dSLin Ming 			break;
204e0fe0a8dSLin Ming 
20595b482a8SLen Brown 		case ACPI_RSD_LONGLIST:
20695b482a8SLen Brown 			/*
20795b482a8SLen Brown 			 * Long byte list for Vendor resource data
20895b482a8SLen Brown 			 * Note: The list length is obtained from the previous table entry
20995b482a8SLen Brown 			 */
21095b482a8SLen Brown 			if (previous_target) {
21195b482a8SLen Brown 				acpi_rs_dump_byte_list(ACPI_GET16
21295b482a8SLen Brown 						       (previous_target),
21395b482a8SLen Brown 						       target);
21495b482a8SLen Brown 			}
21595b482a8SLen Brown 			break;
21695b482a8SLen Brown 
21795b482a8SLen Brown 		case ACPI_RSD_DWORDLIST:
21895b482a8SLen Brown 			/*
21995b482a8SLen Brown 			 * Dword list for Extended Interrupt resources
22095b482a8SLen Brown 			 * Note: The list length is obtained from the previous table entry
22195b482a8SLen Brown 			 */
22295b482a8SLen Brown 			if (previous_target) {
22395b482a8SLen Brown 				acpi_rs_dump_dword_list(*previous_target,
22495b482a8SLen Brown 							ACPI_CAST_PTR(u32,
22595b482a8SLen Brown 								      target));
22695b482a8SLen Brown 			}
22795b482a8SLen Brown 			break;
22895b482a8SLen Brown 
229e0fe0a8dSLin Ming 		case ACPI_RSD_WORDLIST:
230e0fe0a8dSLin Ming 			/*
231e0fe0a8dSLin Ming 			 * Word list for GPIO Pin Table
232e0fe0a8dSLin Ming 			 * Note: The list length is obtained from the previous table entry
233e0fe0a8dSLin Ming 			 */
234e0fe0a8dSLin Ming 			if (previous_target) {
235e0fe0a8dSLin Ming 				acpi_rs_dump_word_list(*previous_target,
236e0fe0a8dSLin Ming 						       *(ACPI_CAST_INDIRECT_PTR
237e0fe0a8dSLin Ming 							 (u16, target)));
238e0fe0a8dSLin Ming 			}
239e0fe0a8dSLin Ming 			break;
240e0fe0a8dSLin Ming 
24195b482a8SLen Brown 		case ACPI_RSD_ADDRESS:
24295b482a8SLen Brown 			/*
24395b482a8SLen Brown 			 * Common flags for all Address resources
24495b482a8SLen Brown 			 */
24595b482a8SLen Brown 			acpi_rs_dump_address_common(ACPI_CAST_PTR
24695b482a8SLen Brown 						    (union acpi_resource_data,
24795b482a8SLen Brown 						     target));
24895b482a8SLen Brown 			break;
24995b482a8SLen Brown 
25095b482a8SLen Brown 		case ACPI_RSD_SOURCE:
25195b482a8SLen Brown 			/*
25295b482a8SLen Brown 			 * Optional resource_source for Address resources
25395b482a8SLen Brown 			 */
2543e8214e5SLv Zheng 			acpi_rs_dump_resource_source(ACPI_CAST_PTR
2553e8214e5SLv Zheng 						     (struct
25695b482a8SLen Brown 								   acpi_resource_source,
25795b482a8SLen Brown 								   target));
25895b482a8SLen Brown 			break;
25995b482a8SLen Brown 
26095b482a8SLen Brown 		default:
26195b482a8SLen Brown 			acpi_os_printf("**** Invalid table opcode [%X] ****\n",
26295b482a8SLen Brown 				       table->opcode);
26395b482a8SLen Brown 			return;
26495b482a8SLen Brown 		}
26595b482a8SLen Brown 
26695b482a8SLen Brown 		table++;
26795b482a8SLen Brown 		count--;
26895b482a8SLen Brown 	}
26995b482a8SLen Brown }
27095b482a8SLen Brown 
27195b482a8SLen Brown /*******************************************************************************
27295b482a8SLen Brown  *
27395b482a8SLen Brown  * FUNCTION:    acpi_rs_dump_resource_source
27495b482a8SLen Brown  *
27595b482a8SLen Brown  * PARAMETERS:  resource_source     - Pointer to a Resource Source struct
27695b482a8SLen Brown  *
27795b482a8SLen Brown  * RETURN:      None
27895b482a8SLen Brown  *
27995b482a8SLen Brown  * DESCRIPTION: Common routine for dumping the optional resource_source and the
28095b482a8SLen Brown  *              corresponding resource_source_index.
28195b482a8SLen Brown  *
28295b482a8SLen Brown  ******************************************************************************/
28395b482a8SLen Brown 
28495b482a8SLen Brown static void
28595b482a8SLen Brown acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
28695b482a8SLen Brown {
28795b482a8SLen Brown 	ACPI_FUNCTION_ENTRY();
28895b482a8SLen Brown 
28995b482a8SLen Brown 	if (resource_source->index == 0xFF) {
29095b482a8SLen Brown 		return;
29195b482a8SLen Brown 	}
29295b482a8SLen Brown 
29395b482a8SLen Brown 	acpi_rs_out_integer8("Resource Source Index", resource_source->index);
29495b482a8SLen Brown 
29595b482a8SLen Brown 	acpi_rs_out_string("Resource Source",
29695b482a8SLen Brown 			   resource_source->string_ptr ?
29795b482a8SLen Brown 			   resource_source->string_ptr : "[Not Specified]");
29895b482a8SLen Brown }
29995b482a8SLen Brown 
30095b482a8SLen Brown /*******************************************************************************
30195b482a8SLen Brown  *
30295b482a8SLen Brown  * FUNCTION:    acpi_rs_dump_address_common
30395b482a8SLen Brown  *
304ba494beeSBob Moore  * PARAMETERS:  resource        - Pointer to an internal resource descriptor
30595b482a8SLen Brown  *
30695b482a8SLen Brown  * RETURN:      None
30795b482a8SLen Brown  *
30895b482a8SLen Brown  * DESCRIPTION: Dump the fields that are common to all Address resource
30995b482a8SLen Brown  *              descriptors
31095b482a8SLen Brown  *
31195b482a8SLen Brown  ******************************************************************************/
31295b482a8SLen Brown 
31395b482a8SLen Brown static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
31495b482a8SLen Brown {
31595b482a8SLen Brown 	ACPI_FUNCTION_ENTRY();
31695b482a8SLen Brown 
31795b482a8SLen Brown 	/* Decode the type-specific flags */
31895b482a8SLen Brown 
31995b482a8SLen Brown 	switch (resource->address.resource_type) {
32095b482a8SLen Brown 	case ACPI_MEMORY_RANGE:
32195b482a8SLen Brown 
32295b482a8SLen Brown 		acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags);
32395b482a8SLen Brown 		break;
32495b482a8SLen Brown 
32595b482a8SLen Brown 	case ACPI_IO_RANGE:
32695b482a8SLen Brown 
32795b482a8SLen Brown 		acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags);
32895b482a8SLen Brown 		break;
32995b482a8SLen Brown 
33095b482a8SLen Brown 	case ACPI_BUS_NUMBER_RANGE:
33195b482a8SLen Brown 
33295b482a8SLen Brown 		acpi_rs_out_string("Resource Type", "Bus Number Range");
33395b482a8SLen Brown 		break;
33495b482a8SLen Brown 
33595b482a8SLen Brown 	default:
33695b482a8SLen Brown 
33795b482a8SLen Brown 		acpi_rs_out_integer8("Resource Type",
33895b482a8SLen Brown 				     (u8) resource->address.resource_type);
33995b482a8SLen Brown 		break;
34095b482a8SLen Brown 	}
34195b482a8SLen Brown 
34295b482a8SLen Brown 	/* Decode the general flags */
34395b482a8SLen Brown 
34495b482a8SLen Brown 	acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags);
34595b482a8SLen Brown }
34695b482a8SLen Brown 
34795b482a8SLen Brown /*******************************************************************************
34895b482a8SLen Brown  *
34995b482a8SLen Brown  * FUNCTION:    acpi_rs_dump_resource_list
35095b482a8SLen Brown  *
35195b482a8SLen Brown  * PARAMETERS:  resource_list       - Pointer to a resource descriptor list
35295b482a8SLen Brown  *
35395b482a8SLen Brown  * RETURN:      None
35495b482a8SLen Brown  *
35595b482a8SLen Brown  * DESCRIPTION: Dispatches the structure to the correct dump routine.
35695b482a8SLen Brown  *
35795b482a8SLen Brown  ******************************************************************************/
35895b482a8SLen Brown 
35995b482a8SLen Brown void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
36095b482a8SLen Brown {
36195b482a8SLen Brown 	u32 count = 0;
36295b482a8SLen Brown 	u32 type;
36395b482a8SLen Brown 
36495b482a8SLen Brown 	ACPI_FUNCTION_ENTRY();
36595b482a8SLen Brown 
36610e9e759SBob Moore 	/* Check if debug output enabled */
36710e9e759SBob Moore 
36810e9e759SBob Moore 	if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
36995b482a8SLen Brown 		return;
37095b482a8SLen Brown 	}
37195b482a8SLen Brown 
37295b482a8SLen Brown 	/* Walk list and dump all resource descriptors (END_TAG terminates) */
37395b482a8SLen Brown 
37495b482a8SLen Brown 	do {
37595b482a8SLen Brown 		acpi_os_printf("\n[%02X] ", count);
37695b482a8SLen Brown 		count++;
37795b482a8SLen Brown 
37895b482a8SLen Brown 		/* Validate Type before dispatch */
37995b482a8SLen Brown 
38095b482a8SLen Brown 		type = resource_list->type;
38195b482a8SLen Brown 		if (type > ACPI_RESOURCE_TYPE_MAX) {
38295b482a8SLen Brown 			acpi_os_printf
38395b482a8SLen Brown 			    ("Invalid descriptor type (%X) in resource list\n",
38495b482a8SLen Brown 			     resource_list->type);
38595b482a8SLen Brown 			return;
38695b482a8SLen Brown 		}
38795b482a8SLen Brown 
38895b482a8SLen Brown 		/* Dump the resource descriptor */
38995b482a8SLen Brown 
390e0fe0a8dSLin Ming 		if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
39195b482a8SLen Brown 			acpi_rs_dump_descriptor(&resource_list->data,
392e0fe0a8dSLin Ming 						acpi_gbl_dump_serial_bus_dispatch
393e0fe0a8dSLin Ming 						[resource_list->data.
394e0fe0a8dSLin Ming 						 common_serial_bus.type]);
395e0fe0a8dSLin Ming 		} else {
396e0fe0a8dSLin Ming 			acpi_rs_dump_descriptor(&resource_list->data,
397e0fe0a8dSLin Ming 						acpi_gbl_dump_resource_dispatch
398e0fe0a8dSLin Ming 						[type]);
399e0fe0a8dSLin Ming 		}
40095b482a8SLen Brown 
40195b482a8SLen Brown 		/* Point to the next resource structure */
40295b482a8SLen Brown 
403e0fe0a8dSLin Ming 		resource_list = ACPI_NEXT_RESOURCE(resource_list);
40495b482a8SLen Brown 
40595b482a8SLen Brown 		/* Exit when END_TAG descriptor is reached */
40695b482a8SLen Brown 
40795b482a8SLen Brown 	} while (type != ACPI_RESOURCE_TYPE_END_TAG);
40895b482a8SLen Brown }
40995b482a8SLen Brown 
41095b482a8SLen Brown /*******************************************************************************
41195b482a8SLen Brown  *
41295b482a8SLen Brown  * FUNCTION:    acpi_rs_dump_irq_list
41395b482a8SLen Brown  *
41495b482a8SLen Brown  * PARAMETERS:  route_table     - Pointer to the routing table to dump.
41595b482a8SLen Brown  *
41695b482a8SLen Brown  * RETURN:      None
41795b482a8SLen Brown  *
41895b482a8SLen Brown  * DESCRIPTION: Print IRQ routing table
41995b482a8SLen Brown  *
42095b482a8SLen Brown  ******************************************************************************/
42195b482a8SLen Brown 
42295b482a8SLen Brown void acpi_rs_dump_irq_list(u8 * route_table)
42395b482a8SLen Brown {
42495b482a8SLen Brown 	struct acpi_pci_routing_table *prt_element;
42595b482a8SLen Brown 	u8 count;
42695b482a8SLen Brown 
42795b482a8SLen Brown 	ACPI_FUNCTION_ENTRY();
42895b482a8SLen Brown 
42910e9e759SBob Moore 	/* Check if debug output enabled */
43010e9e759SBob Moore 
43110e9e759SBob Moore 	if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
43295b482a8SLen Brown 		return;
43395b482a8SLen Brown 	}
43495b482a8SLen Brown 
43595b482a8SLen Brown 	prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table);
43695b482a8SLen Brown 
43795b482a8SLen Brown 	/* Dump all table elements, Exit on zero length element */
43895b482a8SLen Brown 
43995b482a8SLen Brown 	for (count = 0; prt_element->length; count++) {
44095b482a8SLen Brown 		acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
44195b482a8SLen Brown 			       count);
44295b482a8SLen Brown 		acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
44395b482a8SLen Brown 
44495b482a8SLen Brown 		prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
44595b482a8SLen Brown 					   prt_element, prt_element->length);
44695b482a8SLen Brown 	}
44795b482a8SLen Brown }
44895b482a8SLen Brown 
44995b482a8SLen Brown /*******************************************************************************
45095b482a8SLen Brown  *
45195b482a8SLen Brown  * FUNCTION:    acpi_rs_out*
45295b482a8SLen Brown  *
453ba494beeSBob Moore  * PARAMETERS:  title       - Name of the resource field
454ba494beeSBob Moore  *              value       - Value of the resource field
45595b482a8SLen Brown  *
45695b482a8SLen Brown  * RETURN:      None
45795b482a8SLen Brown  *
45895b482a8SLen Brown  * DESCRIPTION: Miscellaneous helper functions to consistently format the
45995b482a8SLen Brown  *              output of the resource dump routines
46095b482a8SLen Brown  *
46195b482a8SLen Brown  ******************************************************************************/
46295b482a8SLen Brown 
46395b482a8SLen Brown static void acpi_rs_out_string(char *title, char *value)
46495b482a8SLen Brown {
46595b482a8SLen Brown 	acpi_os_printf("%27s : %s", title, value);
46695b482a8SLen Brown 	if (!*value) {
46795b482a8SLen Brown 		acpi_os_printf("[NULL NAMESTRING]");
46895b482a8SLen Brown 	}
46995b482a8SLen Brown 	acpi_os_printf("\n");
47095b482a8SLen Brown }
47195b482a8SLen Brown 
47295b482a8SLen Brown static void acpi_rs_out_integer8(char *title, u8 value)
47395b482a8SLen Brown {
47495b482a8SLen Brown 	acpi_os_printf("%27s : %2.2X\n", title, value);
47595b482a8SLen Brown }
47695b482a8SLen Brown 
47795b482a8SLen Brown static void acpi_rs_out_integer16(char *title, u16 value)
47895b482a8SLen Brown {
47995b482a8SLen Brown 	acpi_os_printf("%27s : %4.4X\n", title, value);
48095b482a8SLen Brown }
48195b482a8SLen Brown 
48295b482a8SLen Brown static void acpi_rs_out_integer32(char *title, u32 value)
48395b482a8SLen Brown {
48495b482a8SLen Brown 	acpi_os_printf("%27s : %8.8X\n", title, value);
48595b482a8SLen Brown }
48695b482a8SLen Brown 
48795b482a8SLen Brown static void acpi_rs_out_integer64(char *title, u64 value)
48895b482a8SLen Brown {
48995b482a8SLen Brown 	acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
49095b482a8SLen Brown }
49195b482a8SLen Brown 
49295b482a8SLen Brown static void acpi_rs_out_title(char *title)
49395b482a8SLen Brown {
49495b482a8SLen Brown 	acpi_os_printf("%27s : ", title);
49595b482a8SLen Brown }
49695b482a8SLen Brown 
49795b482a8SLen Brown /*******************************************************************************
49895b482a8SLen Brown  *
49995b482a8SLen Brown  * FUNCTION:    acpi_rs_dump*List
50095b482a8SLen Brown  *
501ba494beeSBob Moore  * PARAMETERS:  length      - Number of elements in the list
502ba494beeSBob Moore  *              data        - Start of the list
50395b482a8SLen Brown  *
50495b482a8SLen Brown  * RETURN:      None
50595b482a8SLen Brown  *
50695b482a8SLen Brown  * DESCRIPTION: Miscellaneous functions to dump lists of raw data
50795b482a8SLen Brown  *
50895b482a8SLen Brown  ******************************************************************************/
50995b482a8SLen Brown 
51095b482a8SLen Brown static void acpi_rs_dump_byte_list(u16 length, u8 * data)
51195b482a8SLen Brown {
51295b482a8SLen Brown 	u8 i;
51395b482a8SLen Brown 
51495b482a8SLen Brown 	for (i = 0; i < length; i++) {
51595b482a8SLen Brown 		acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
51695b482a8SLen Brown 	}
51795b482a8SLen Brown }
51895b482a8SLen Brown 
51995b482a8SLen Brown static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
52095b482a8SLen Brown {
52195b482a8SLen Brown 	u8 i;
52295b482a8SLen Brown 
52395b482a8SLen Brown 	for (i = 0; i < length; i++) {
52495b482a8SLen Brown 		acpi_os_printf("%X ", data[i]);
52595b482a8SLen Brown 	}
52695b482a8SLen Brown 	acpi_os_printf("\n");
52795b482a8SLen Brown }
52895b482a8SLen Brown 
52995b482a8SLen Brown static void acpi_rs_dump_dword_list(u8 length, u32 * data)
53095b482a8SLen Brown {
53195b482a8SLen Brown 	u8 i;
53295b482a8SLen Brown 
53395b482a8SLen Brown 	for (i = 0; i < length; i++) {
53495b482a8SLen Brown 		acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
53595b482a8SLen Brown 	}
53695b482a8SLen Brown }
53795b482a8SLen Brown 
538e0fe0a8dSLin Ming static void acpi_rs_dump_word_list(u16 length, u16 *data)
539e0fe0a8dSLin Ming {
540e0fe0a8dSLin Ming 	u16 i;
541e0fe0a8dSLin Ming 
542e0fe0a8dSLin Ming 	for (i = 0; i < length; i++) {
543e0fe0a8dSLin Ming 		acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i, data[i]);
544e0fe0a8dSLin Ming 	}
545e0fe0a8dSLin Ming }
546e0fe0a8dSLin Ming 
54795b482a8SLen Brown #endif
548