mm/zsmalloc: allocate exactly size of struct zs_pool
[linux/fpc-iii.git] / drivers / acpi / acpica / rsdump.c
blobc3c56b5a9788319cec129216882bd4d9cf8faebc
1 /*******************************************************************************
3 * Module Name: rsdump - Functions to display the resource structures.
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include "accommon.h"
46 #include "acresrc.h"
48 #define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME("rsdump")
51 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER)
52 /* Local prototypes */
53 static void acpi_rs_out_string(char *title, char *value);
55 static void acpi_rs_out_integer8(char *title, u8 value);
57 static void acpi_rs_out_integer16(char *title, u16 value);
59 static void acpi_rs_out_integer32(char *title, u32 value);
61 static void acpi_rs_out_integer64(char *title, u64 value);
63 static void acpi_rs_out_title(char *title);
65 static void acpi_rs_dump_byte_list(u16 length, u8 *data);
67 static void acpi_rs_dump_word_list(u16 length, u16 *data);
69 static void acpi_rs_dump_dword_list(u8 length, u32 *data);
71 static void acpi_rs_dump_short_byte_list(u8 length, u8 *data);
73 static void
74 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
76 static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
78 static void
79 acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
81 /*******************************************************************************
83 * FUNCTION: acpi_rs_dump_descriptor
85 * PARAMETERS: resource - Buffer containing the resource
86 * table - Table entry to decode the resource
88 * RETURN: None
90 * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
92 ******************************************************************************/
94 static void
95 acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
97 u8 *target = NULL;
98 u8 *previous_target;
99 char *name;
100 u8 count;
102 /* First table entry must contain the table length (# of table entries) */
104 count = table->offset;
106 while (count) {
107 previous_target = target;
108 target = ACPI_ADD_PTR(u8, resource, table->offset);
109 name = table->name;
111 switch (table->opcode) {
112 case ACPI_RSD_TITLE:
114 * Optional resource title
116 if (table->name) {
117 acpi_os_printf("%s Resource\n", name);
119 break;
121 /* Strings */
123 case ACPI_RSD_LITERAL:
125 acpi_rs_out_string(name,
126 ACPI_CAST_PTR(char, table->pointer));
127 break;
129 case ACPI_RSD_STRING:
131 acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
132 break;
134 /* Data items, 8/16/32/64 bit */
136 case ACPI_RSD_UINT8:
138 if (table->pointer) {
139 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
140 table->
141 pointer
142 [*target]));
143 } else {
144 acpi_rs_out_integer8(name, ACPI_GET8(target));
146 break;
148 case ACPI_RSD_UINT16:
150 acpi_rs_out_integer16(name, ACPI_GET16(target));
151 break;
153 case ACPI_RSD_UINT32:
155 acpi_rs_out_integer32(name, ACPI_GET32(target));
156 break;
158 case ACPI_RSD_UINT64:
160 acpi_rs_out_integer64(name, ACPI_GET64(target));
161 break;
163 /* Flags: 1-bit and 2-bit flags supported */
165 case ACPI_RSD_1BITFLAG:
167 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
168 table->
169 pointer[*target &
170 0x01]));
171 break;
173 case ACPI_RSD_2BITFLAG:
175 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
176 table->
177 pointer[*target &
178 0x03]));
179 break;
181 case ACPI_RSD_3BITFLAG:
183 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
184 table->
185 pointer[*target &
186 0x07]));
187 break;
189 case ACPI_RSD_SHORTLIST:
191 * Short byte list (single line output) for DMA and IRQ resources
192 * Note: The list length is obtained from the previous table entry
194 if (previous_target) {
195 acpi_rs_out_title(name);
196 acpi_rs_dump_short_byte_list(*previous_target,
197 target);
199 break;
201 case ACPI_RSD_SHORTLISTX:
203 * Short byte list (single line output) for GPIO vendor data
204 * Note: The list length is obtained from the previous table entry
206 if (previous_target) {
207 acpi_rs_out_title(name);
208 acpi_rs_dump_short_byte_list(*previous_target,
210 (ACPI_CAST_INDIRECT_PTR
211 (u8, target)));
213 break;
215 case ACPI_RSD_LONGLIST:
217 * Long byte list for Vendor resource data
218 * Note: The list length is obtained from the previous table entry
220 if (previous_target) {
221 acpi_rs_dump_byte_list(ACPI_GET16
222 (previous_target),
223 target);
225 break;
227 case ACPI_RSD_DWORDLIST:
229 * Dword list for Extended Interrupt resources
230 * Note: The list length is obtained from the previous table entry
232 if (previous_target) {
233 acpi_rs_dump_dword_list(*previous_target,
234 ACPI_CAST_PTR(u32,
235 target));
237 break;
239 case ACPI_RSD_WORDLIST:
241 * Word list for GPIO Pin Table
242 * Note: The list length is obtained from the previous table entry
244 if (previous_target) {
245 acpi_rs_dump_word_list(*previous_target,
246 *(ACPI_CAST_INDIRECT_PTR
247 (u16, target)));
249 break;
251 case ACPI_RSD_ADDRESS:
253 * Common flags for all Address resources
255 acpi_rs_dump_address_common(ACPI_CAST_PTR
256 (union acpi_resource_data,
257 target));
258 break;
260 case ACPI_RSD_SOURCE:
262 * Optional resource_source for Address resources
264 acpi_rs_dump_resource_source(ACPI_CAST_PTR
265 (struct
266 acpi_resource_source,
267 target));
268 break;
270 default:
272 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
273 table->opcode);
274 return;
277 table++;
278 count--;
282 /*******************************************************************************
284 * FUNCTION: acpi_rs_dump_resource_source
286 * PARAMETERS: resource_source - Pointer to a Resource Source struct
288 * RETURN: None
290 * DESCRIPTION: Common routine for dumping the optional resource_source and the
291 * corresponding resource_source_index.
293 ******************************************************************************/
295 static void
296 acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
298 ACPI_FUNCTION_ENTRY();
300 if (resource_source->index == 0xFF) {
301 return;
304 acpi_rs_out_integer8("Resource Source Index", resource_source->index);
306 acpi_rs_out_string("Resource Source",
307 resource_source->string_ptr ?
308 resource_source->string_ptr : "[Not Specified]");
311 /*******************************************************************************
313 * FUNCTION: acpi_rs_dump_address_common
315 * PARAMETERS: resource - Pointer to an internal resource descriptor
317 * RETURN: None
319 * DESCRIPTION: Dump the fields that are common to all Address resource
320 * descriptors
322 ******************************************************************************/
324 static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
326 ACPI_FUNCTION_ENTRY();
328 /* Decode the type-specific flags */
330 switch (resource->address.resource_type) {
331 case ACPI_MEMORY_RANGE:
333 acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags);
334 break;
336 case ACPI_IO_RANGE:
338 acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags);
339 break;
341 case ACPI_BUS_NUMBER_RANGE:
343 acpi_rs_out_string("Resource Type", "Bus Number Range");
344 break;
346 default:
348 acpi_rs_out_integer8("Resource Type",
349 (u8) resource->address.resource_type);
350 break;
353 /* Decode the general flags */
355 acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags);
358 /*******************************************************************************
360 * FUNCTION: acpi_rs_dump_resource_list
362 * PARAMETERS: resource_list - Pointer to a resource descriptor list
364 * RETURN: None
366 * DESCRIPTION: Dispatches the structure to the correct dump routine.
368 ******************************************************************************/
370 void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
372 u32 count = 0;
373 u32 type;
375 ACPI_FUNCTION_ENTRY();
377 /* Check if debug output enabled */
379 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
380 return;
383 /* Walk list and dump all resource descriptors (END_TAG terminates) */
385 do {
386 acpi_os_printf("\n[%02X] ", count);
387 count++;
389 /* Validate Type before dispatch */
391 type = resource_list->type;
392 if (type > ACPI_RESOURCE_TYPE_MAX) {
393 acpi_os_printf
394 ("Invalid descriptor type (%X) in resource list\n",
395 resource_list->type);
396 return;
399 /* Sanity check the length. It must not be zero, or we loop forever */
401 if (!resource_list->length) {
402 acpi_os_printf
403 ("Invalid zero length descriptor in resource list\n");
404 return;
407 /* Dump the resource descriptor */
409 if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
410 acpi_rs_dump_descriptor(&resource_list->data,
411 acpi_gbl_dump_serial_bus_dispatch
412 [resource_list->data.
413 common_serial_bus.type]);
414 } else {
415 acpi_rs_dump_descriptor(&resource_list->data,
416 acpi_gbl_dump_resource_dispatch
417 [type]);
420 /* Point to the next resource structure */
422 resource_list = ACPI_NEXT_RESOURCE(resource_list);
424 /* Exit when END_TAG descriptor is reached */
426 } while (type != ACPI_RESOURCE_TYPE_END_TAG);
429 /*******************************************************************************
431 * FUNCTION: acpi_rs_dump_irq_list
433 * PARAMETERS: route_table - Pointer to the routing table to dump.
435 * RETURN: None
437 * DESCRIPTION: Print IRQ routing table
439 ******************************************************************************/
441 void acpi_rs_dump_irq_list(u8 * route_table)
443 struct acpi_pci_routing_table *prt_element;
444 u8 count;
446 ACPI_FUNCTION_ENTRY();
448 /* Check if debug output enabled */
450 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
451 return;
454 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table);
456 /* Dump all table elements, Exit on zero length element */
458 for (count = 0; prt_element->length; count++) {
459 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
460 count);
461 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
463 prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
464 prt_element, prt_element->length);
468 /*******************************************************************************
470 * FUNCTION: acpi_rs_out*
472 * PARAMETERS: title - Name of the resource field
473 * value - Value of the resource field
475 * RETURN: None
477 * DESCRIPTION: Miscellaneous helper functions to consistently format the
478 * output of the resource dump routines
480 ******************************************************************************/
482 static void acpi_rs_out_string(char *title, char *value)
484 acpi_os_printf("%27s : %s", title, value);
485 if (!*value) {
486 acpi_os_printf("[NULL NAMESTRING]");
488 acpi_os_printf("\n");
491 static void acpi_rs_out_integer8(char *title, u8 value)
493 acpi_os_printf("%27s : %2.2X\n", title, value);
496 static void acpi_rs_out_integer16(char *title, u16 value)
498 acpi_os_printf("%27s : %4.4X\n", title, value);
501 static void acpi_rs_out_integer32(char *title, u32 value)
503 acpi_os_printf("%27s : %8.8X\n", title, value);
506 static void acpi_rs_out_integer64(char *title, u64 value)
508 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
511 static void acpi_rs_out_title(char *title)
513 acpi_os_printf("%27s : ", title);
516 /*******************************************************************************
518 * FUNCTION: acpi_rs_dump*List
520 * PARAMETERS: length - Number of elements in the list
521 * data - Start of the list
523 * RETURN: None
525 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
527 ******************************************************************************/
529 static void acpi_rs_dump_byte_list(u16 length, u8 * data)
531 u8 i;
533 for (i = 0; i < length; i++) {
534 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
538 static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
540 u8 i;
542 for (i = 0; i < length; i++) {
543 acpi_os_printf("%X ", data[i]);
545 acpi_os_printf("\n");
548 static void acpi_rs_dump_dword_list(u8 length, u32 * data)
550 u8 i;
552 for (i = 0; i < length; i++) {
553 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
557 static void acpi_rs_dump_word_list(u16 length, u16 *data)
559 u16 i;
561 for (i = 0; i < length; i++) {
562 acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i, data[i]);
566 #endif