blob: cc0ae39440e4358838626c73c63d43ccc8e15d01 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: nsdump - table dumping routines for debug
4 *
5 *****************************************************************************/
6
7/*
Len Brown75a44ce2008-04-23 23:00:13 -04008 * Copyright (C) 2000 - 2008, 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>
45#include <acpi/acnamesp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define _COMPONENT ACPI_NAMESPACE
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("nsdump")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Robert Moore44f6c012005-04-18 22:49:35 -040050/* Local prototypes */
Robert Moore44f6c012005-04-18 22:49:35 -040051#ifdef ACPI_OBSOLETE_FUNCTIONS
Len Brown4be44fc2005-08-05 00:44:28 -040052void acpi_ns_dump_root_devices(void);
Robert Moore44f6c012005-04-18 22:49:35 -040053
54static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040055acpi_ns_dump_one_device(acpi_handle obj_handle,
56 u32 level, void *context, void **return_value);
Robert Moore44f6c012005-04-18 22:49:35 -040057#endif
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060/*******************************************************************************
61 *
62 * FUNCTION: acpi_ns_print_pathname
63 *
Robert Moore44f6c012005-04-18 22:49:35 -040064 * PARAMETERS: num_segments - Number of ACPI name segments
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 * Pathname - The compressed (internal) path
66 *
Robert Moore44f6c012005-04-18 22:49:35 -040067 * RETURN: None
68 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 * DESCRIPTION: Print an object's full namespace pathname
70 *
71 ******************************************************************************/
72
Len Brown4be44fc2005-08-05 00:44:28 -040073void acpi_ns_print_pathname(u32 num_segments, char *pathname)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074{
Bob Moore67a119f2008-06-10 13:42:13 +080075 u32 i;
Robert Moore0c9938c2005-07-29 15:15:00 -070076
Bob Mooreb229cf92006-04-21 17:15:00 -040077 ACPI_FUNCTION_NAME(ns_print_pathname);
Robert Moore0c9938c2005-07-29 15:15:00 -070078
Len Brown4be44fc2005-08-05 00:44:28 -040079 if (!(acpi_dbg_level & ACPI_LV_NAMES)
80 || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 return;
82 }
83
84 /* Print the entire name */
85
Len Brown4be44fc2005-08-05 00:44:28 -040086 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "["));
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88 while (num_segments) {
Robert Moore0c9938c2005-07-29 15:15:00 -070089 for (i = 0; i < 4; i++) {
Len Brown4be44fc2005-08-05 00:44:28 -040090 ACPI_IS_PRINT(pathname[i]) ?
91 acpi_os_printf("%c", pathname[i]) :
92 acpi_os_printf("?");
Robert Moore0c9938c2005-07-29 15:15:00 -070093 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Robert Moore0c9938c2005-07-29 15:15:00 -070095 pathname += ACPI_NAME_SIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 num_segments--;
97 if (num_segments) {
Len Brown4be44fc2005-08-05 00:44:28 -040098 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 }
100 }
101
Len Brown4be44fc2005-08-05 00:44:28 -0400102 acpi_os_printf("]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103}
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105/*******************************************************************************
106 *
107 * FUNCTION: acpi_ns_dump_pathname
108 *
109 * PARAMETERS: Handle - Object
110 * Msg - Prefix message
111 * Level - Desired debug level
112 * Component - Caller's component ID
113 *
Robert Moore44f6c012005-04-18 22:49:35 -0400114 * RETURN: None
115 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 * DESCRIPTION: Print an object's full namespace pathname
117 * Manages allocation/freeing of a pathname buffer
118 *
119 ******************************************************************************/
120
121void
Len Brown4be44fc2005-08-05 00:44:28 -0400122acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123{
124
Bob Mooreb229cf92006-04-21 17:15:00 -0400125 ACPI_FUNCTION_TRACE(ns_dump_pathname);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
127 /* Do this only if the requested debug level and component are enabled */
128
129 if (!(acpi_dbg_level & level) || !(acpi_dbg_layer & component)) {
130 return_VOID;
131 }
132
133 /* Convert handle to a full pathname and print it (with supplied message) */
134
Len Brown4be44fc2005-08-05 00:44:28 -0400135 acpi_ns_print_node_pathname(handle, msg);
136 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 return_VOID;
138}
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/*******************************************************************************
141 *
142 * FUNCTION: acpi_ns_dump_one_object
143 *
Robert Moore44f6c012005-04-18 22:49:35 -0400144 * PARAMETERS: obj_handle - Node to be dumped
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 * Level - Nesting level of the handle
146 * Context - Passed into walk_namespace
Robert Moore44f6c012005-04-18 22:49:35 -0400147 * return_value - Not used
148 *
149 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 *
151 * DESCRIPTION: Dump a single Node
152 * This procedure is a user_function called by acpi_ns_walk_namespace.
153 *
154 ******************************************************************************/
155
156acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400157acpi_ns_dump_one_object(acpi_handle obj_handle,
158 u32 level, void *context, void **return_value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159{
Len Brown4be44fc2005-08-05 00:44:28 -0400160 struct acpi_walk_info *info = (struct acpi_walk_info *)context;
161 struct acpi_namespace_node *this_node;
162 union acpi_operand_object *obj_desc = NULL;
163 acpi_object_type obj_type;
164 acpi_object_type type;
165 u32 bytes_to_dump;
166 u32 dbg_level;
167 u32 i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
Bob Mooreb229cf92006-04-21 17:15:00 -0400169 ACPI_FUNCTION_NAME(ns_dump_one_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
171 /* Is output enabled? */
172
173 if (!(acpi_dbg_level & info->debug_level)) {
174 return (AE_OK);
175 }
176
177 if (!obj_handle) {
Len Brown4be44fc2005-08-05 00:44:28 -0400178 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 return (AE_OK);
180 }
181
Len Brown4be44fc2005-08-05 00:44:28 -0400182 this_node = acpi_ns_map_handle_to_node(obj_handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 type = this_node->type;
184
185 /* Check if the owner matches */
186
Robert Mooref9f46012005-07-08 00:00:00 -0400187 if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
Len Brown4be44fc2005-08-05 00:44:28 -0400188 (info->owner_id != this_node->owner_id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 return (AE_OK);
190 }
191
Robert Moore73459f72005-06-24 00:00:00 -0400192 if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400193
Robert Moore73459f72005-06-24 00:00:00 -0400194 /* Indent the object according to the level */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
Len Brown4be44fc2005-08-05 00:44:28 -0400196 acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Robert Moore73459f72005-06-24 00:00:00 -0400198 /* Check the node type and name */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
Robert Moore73459f72005-06-24 00:00:00 -0400200 if (type > ACPI_TYPE_LOCAL_MAX) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500201 ACPI_WARNING((AE_INFO, "Invalid ACPI Object Type %08X",
202 type));
Robert Moore73459f72005-06-24 00:00:00 -0400203 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Len Brown4be44fc2005-08-05 00:44:28 -0400205 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
Bob Moore793c2382006-03-31 00:00:00 -0500206 this_node->name.integer =
Bob Moore3d81b232007-02-02 19:48:19 +0300207 acpi_ut_repair_name(this_node->name.ascii);
Bob Moore793c2382006-03-31 00:00:00 -0500208
Bob Mooreb8e4d892006-01-27 16:43:00 -0500209 ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X",
210 this_node->name.integer));
Robert Moore73459f72005-06-24 00:00:00 -0400211 }
212
Len Brown4be44fc2005-08-05 00:44:28 -0400213 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 }
215
216 /*
217 * Now we can print out the pertinent information
218 */
Bob Moore28f55eb2005-12-02 18:27:00 -0500219 acpi_os_printf(" %-12s %p %2.2X ",
220 acpi_ut_get_type_name(type), this_node,
221 this_node->owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223 dbg_level = acpi_dbg_level;
224 acpi_dbg_level = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400225 obj_desc = acpi_ns_get_attached_object(this_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 acpi_dbg_level = dbg_level;
227
Bob Moored1fdda832007-02-02 19:48:21 +0300228 /* Temp nodes are those nodes created by a control method */
229
230 if (this_node->flags & ANOBJ_TEMPORARY) {
231 acpi_os_printf("(T) ");
232 }
233
Robert Moore73459f72005-06-24 00:00:00 -0400234 switch (info->display_type & ACPI_DISPLAY_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 case ACPI_DISPLAY_SUMMARY:
236
237 if (!obj_desc) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 /* No attached object, we are done */
240
Len Brown4be44fc2005-08-05 00:44:28 -0400241 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 return (AE_OK);
243 }
244
245 switch (type) {
246 case ACPI_TYPE_PROCESSOR:
247
Len Brown4be44fc2005-08-05 00:44:28 -0400248 acpi_os_printf("ID %X Len %.4X Addr %p\n",
249 obj_desc->processor.proc_id,
250 obj_desc->processor.length,
Bob Moore1d18c052008-04-10 19:06:40 +0400251 ACPI_CAST_PTR(void,
252 obj_desc->processor.
253 address));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 break;
255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 case ACPI_TYPE_DEVICE:
257
Len Brown4be44fc2005-08-05 00:44:28 -0400258 acpi_os_printf("Notify Object: %p\n", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 break;
260
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 case ACPI_TYPE_METHOD:
262
Len Brown4be44fc2005-08-05 00:44:28 -0400263 acpi_os_printf("Args %X Len %.4X Aml %p\n",
264 (u32) obj_desc->method.param_count,
265 obj_desc->method.aml_length,
266 obj_desc->method.aml_start);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 break;
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 case ACPI_TYPE_INTEGER:
270
Len Brown4be44fc2005-08-05 00:44:28 -0400271 acpi_os_printf("= %8.8X%8.8X\n",
272 ACPI_FORMAT_UINT64(obj_desc->integer.
273 value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 break;
275
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 case ACPI_TYPE_PACKAGE:
277
278 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400279 acpi_os_printf("Elements %.2X\n",
280 obj_desc->package.count);
281 } else {
282 acpi_os_printf("[Length not yet evaluated]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 }
284 break;
285
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 case ACPI_TYPE_BUFFER:
287
288 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400289 acpi_os_printf("Len %.2X",
290 obj_desc->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
292 /* Dump some of the buffer */
293
294 if (obj_desc->buffer.length > 0) {
Len Brown4be44fc2005-08-05 00:44:28 -0400295 acpi_os_printf(" =");
296 for (i = 0;
297 (i < obj_desc->buffer.length
298 && i < 12); i++) {
299 acpi_os_printf(" %.2hX",
300 obj_desc->buffer.
301 pointer[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 }
303 }
Len Brown4be44fc2005-08-05 00:44:28 -0400304 acpi_os_printf("\n");
305 } else {
306 acpi_os_printf("[Length not yet evaluated]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 }
308 break;
309
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 case ACPI_TYPE_STRING:
311
Len Brown4be44fc2005-08-05 00:44:28 -0400312 acpi_os_printf("Len %.2X ", obj_desc->string.length);
313 acpi_ut_print_string(obj_desc->string.pointer, 32);
314 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 break;
316
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 case ACPI_TYPE_REGION:
318
Len Brown4be44fc2005-08-05 00:44:28 -0400319 acpi_os_printf("[%s]",
320 acpi_ut_get_region_name(obj_desc->region.
321 space_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400323 acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
Bob Moore1d18c052008-04-10 19:06:40 +0400324 ACPI_FORMAT_NATIVE_UINT
325 (obj_desc->region.address),
Len Brown4be44fc2005-08-05 00:44:28 -0400326 obj_desc->region.length);
327 } else {
328 acpi_os_printf
329 (" [Address/Length not yet evaluated]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 }
331 break;
332
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 case ACPI_TYPE_LOCAL_REFERENCE:
334
Len Brown4be44fc2005-08-05 00:44:28 -0400335 acpi_os_printf("[%s]\n",
Bob Moore1044f1f2008-09-27 11:08:41 +0800336 acpi_ut_get_reference_name(obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 break;
338
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 case ACPI_TYPE_BUFFER_FIELD:
340
341 if (obj_desc->buffer_field.buffer_obj &&
Len Brown4be44fc2005-08-05 00:44:28 -0400342 obj_desc->buffer_field.buffer_obj->buffer.node) {
343 acpi_os_printf("Buf [%4.4s]",
344 acpi_ut_get_node_name(obj_desc->
345 buffer_field.
346 buffer_obj->
347 buffer.
348 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 }
350 break;
351
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 case ACPI_TYPE_LOCAL_REGION_FIELD:
353
Len Brown4be44fc2005-08-05 00:44:28 -0400354 acpi_os_printf("Rgn [%4.4s]",
355 acpi_ut_get_node_name(obj_desc->
356 common_field.
357 region_obj->region.
358 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 break;
360
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 case ACPI_TYPE_LOCAL_BANK_FIELD:
362
Len Brown4be44fc2005-08-05 00:44:28 -0400363 acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
364 acpi_ut_get_node_name(obj_desc->
365 common_field.
366 region_obj->region.
367 node),
368 acpi_ut_get_node_name(obj_desc->
369 bank_field.
370 bank_obj->
371 common_field.
372 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 break;
374
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 case ACPI_TYPE_LOCAL_INDEX_FIELD:
376
Len Brown4be44fc2005-08-05 00:44:28 -0400377 acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
378 acpi_ut_get_node_name(obj_desc->
379 index_field.
380 index_obj->
381 common_field.node),
382 acpi_ut_get_node_name(obj_desc->
383 index_field.
384 data_obj->
385 common_field.
386 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 break;
388
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 case ACPI_TYPE_LOCAL_ALIAS:
390 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
391
Len Brown4be44fc2005-08-05 00:44:28 -0400392 acpi_os_printf("Target %4.4s (%p)\n",
393 acpi_ut_get_node_name(obj_desc),
394 obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 break;
396
397 default:
398
Len Brown4be44fc2005-08-05 00:44:28 -0400399 acpi_os_printf("Object %p\n", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 break;
401 }
402
403 /* Common field handling */
404
405 switch (type) {
406 case ACPI_TYPE_BUFFER_FIELD:
407 case ACPI_TYPE_LOCAL_REGION_FIELD:
408 case ACPI_TYPE_LOCAL_BANK_FIELD:
409 case ACPI_TYPE_LOCAL_INDEX_FIELD:
410
Len Brown4be44fc2005-08-05 00:44:28 -0400411 acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
412 (obj_desc->common_field.
413 base_byte_offset * 8)
414 +
415 obj_desc->common_field.
416 start_field_bit_offset,
417 obj_desc->common_field.bit_length,
418 obj_desc->common_field.
419 access_byte_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 break;
421
422 default:
423 break;
424 }
425 break;
426
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 case ACPI_DISPLAY_OBJECTS:
428
Len Brown4be44fc2005-08-05 00:44:28 -0400429 acpi_os_printf("O:%p", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 if (!obj_desc) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400431
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 /* No attached object, we are done */
433
Len Brown4be44fc2005-08-05 00:44:28 -0400434 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 return (AE_OK);
436 }
437
Len Brown4be44fc2005-08-05 00:44:28 -0400438 acpi_os_printf("(R%d)", obj_desc->common.reference_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
440 switch (type) {
441 case ACPI_TYPE_METHOD:
442
443 /* Name is a Method and its AML offset/length are set */
444
Len Brown4be44fc2005-08-05 00:44:28 -0400445 acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start,
446 obj_desc->method.aml_length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 break;
448
449 case ACPI_TYPE_INTEGER:
450
Len Brown4be44fc2005-08-05 00:44:28 -0400451 acpi_os_printf(" I:%8.8X8.8%X\n",
452 ACPI_FORMAT_UINT64(obj_desc->integer.
453 value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 break;
455
456 case ACPI_TYPE_STRING:
457
Len Brown4be44fc2005-08-05 00:44:28 -0400458 acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
459 obj_desc->string.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 break;
461
462 case ACPI_TYPE_BUFFER:
463
Len Brown4be44fc2005-08-05 00:44:28 -0400464 acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
465 obj_desc->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 break;
467
468 default:
469
Len Brown4be44fc2005-08-05 00:44:28 -0400470 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 break;
472 }
473 break;
474
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 default:
Len Brown4be44fc2005-08-05 00:44:28 -0400476 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 break;
478 }
479
480 /* If debug turned off, done */
481
482 if (!(acpi_dbg_level & ACPI_LV_VALUES)) {
483 return (AE_OK);
484 }
485
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 /* If there is an attached object, display it */
487
Len Brown4be44fc2005-08-05 00:44:28 -0400488 dbg_level = acpi_dbg_level;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 acpi_dbg_level = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400490 obj_desc = acpi_ns_get_attached_object(this_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 acpi_dbg_level = dbg_level;
492
493 /* Dump attached objects */
494
495 while (obj_desc) {
496 obj_type = ACPI_TYPE_INVALID;
Len Brown4be44fc2005-08-05 00:44:28 -0400497 acpi_os_printf("Attached Object %p: ", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
499 /* Decode the type of attached object and dump the contents */
500
Len Brown4be44fc2005-08-05 00:44:28 -0400501 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 case ACPI_DESC_TYPE_NAMED:
503
Len Brown4be44fc2005-08-05 00:44:28 -0400504 acpi_os_printf("(Ptr to Node)\n");
505 bytes_to_dump = sizeof(struct acpi_namespace_node);
506 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 break;
508
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 case ACPI_DESC_TYPE_OPERAND:
510
Len Brown4be44fc2005-08-05 00:44:28 -0400511 obj_type = ACPI_GET_OBJECT_TYPE(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512
513 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
Len Brown4be44fc2005-08-05 00:44:28 -0400514 acpi_os_printf
Bob Moore71d993e2008-06-10 14:25:05 +0800515 ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400516 obj_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 bytes_to_dump = 32;
Len Brown4be44fc2005-08-05 00:44:28 -0400518 } else {
519 acpi_os_printf
Bob Moore71d993e2008-06-10 14:25:05 +0800520 ("(Pointer to ACPI Object type %.2X [%s])\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400521 obj_type, acpi_ut_get_type_name(obj_type));
522 bytes_to_dump =
523 sizeof(union acpi_operand_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525
Len Brown4be44fc2005-08-05 00:44:28 -0400526 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
Robert Moore6f42ccf2005-05-13 00:00:00 -0400527 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528
529 default:
530
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 break;
532 }
533
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 /* If value is NOT an internal object, we are done */
535
Len Brown4be44fc2005-08-05 00:44:28 -0400536 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
537 ACPI_DESC_TYPE_OPERAND) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 goto cleanup;
539 }
540
541 /*
542 * Valid object, get the pointer to next level, if any
543 */
544 switch (obj_type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 case ACPI_TYPE_BUFFER:
Robert Moore6f42ccf2005-05-13 00:00:00 -0400546 case ACPI_TYPE_STRING:
547 /*
548 * NOTE: takes advantage of common fields between string/buffer
549 */
550 bytes_to_dump = obj_desc->string.length;
Len Brown4be44fc2005-08-05 00:44:28 -0400551 obj_desc = (void *)obj_desc->string.pointer;
552 acpi_os_printf("(Buffer/String pointer %p length %X)\n",
553 obj_desc, bytes_to_dump);
554 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
Robert Moore6f42ccf2005-05-13 00:00:00 -0400555 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556
557 case ACPI_TYPE_BUFFER_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400558 obj_desc =
559 (union acpi_operand_object *)obj_desc->buffer_field.
560 buffer_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 break;
562
563 case ACPI_TYPE_PACKAGE:
Len Brown4be44fc2005-08-05 00:44:28 -0400564 obj_desc = (void *)obj_desc->package.elements;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 break;
566
567 case ACPI_TYPE_METHOD:
Len Brown4be44fc2005-08-05 00:44:28 -0400568 obj_desc = (void *)obj_desc->method.aml_start;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 break;
570
571 case ACPI_TYPE_LOCAL_REGION_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400572 obj_desc = (void *)obj_desc->field.region_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 break;
574
575 case ACPI_TYPE_LOCAL_BANK_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400576 obj_desc = (void *)obj_desc->bank_field.region_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 break;
578
579 case ACPI_TYPE_LOCAL_INDEX_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400580 obj_desc = (void *)obj_desc->index_field.index_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 break;
582
583 default:
584 goto cleanup;
585 }
586
Len Brown4be44fc2005-08-05 00:44:28 -0400587 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 }
589
Len Brown4be44fc2005-08-05 00:44:28 -0400590 cleanup:
591 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 return (AE_OK);
593}
594
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595#ifdef ACPI_FUTURE_USAGE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596/*******************************************************************************
597 *
598 * FUNCTION: acpi_ns_dump_objects
599 *
600 * PARAMETERS: Type - Object type to be dumped
Robert Moore44f6c012005-04-18 22:49:35 -0400601 * display_type - 0 or ACPI_DISPLAY_SUMMARY
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
603 * for an effectively unlimited depth.
604 * owner_id - Dump only objects owned by this ID. Use
605 * ACPI_UINT32_MAX to match all owners.
606 * start_handle - Where in namespace to start/end search
607 *
Robert Moore44f6c012005-04-18 22:49:35 -0400608 * RETURN: None
609 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 * DESCRIPTION: Dump typed objects within the loaded namespace.
611 * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
612 *
613 ******************************************************************************/
614
615void
Len Brown4be44fc2005-08-05 00:44:28 -0400616acpi_ns_dump_objects(acpi_object_type type,
617 u8 display_type,
618 u32 max_depth,
619 acpi_owner_id owner_id, acpi_handle start_handle)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620{
Len Brown4be44fc2005-08-05 00:44:28 -0400621 struct acpi_walk_info info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622
Len Brown4be44fc2005-08-05 00:44:28 -0400623 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
625 info.debug_level = ACPI_LV_TABLES;
626 info.owner_id = owner_id;
627 info.display_type = display_type;
628
Len Brown4be44fc2005-08-05 00:44:28 -0400629 (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
Bob Moored1fdda832007-02-02 19:48:21 +0300630 ACPI_NS_WALK_NO_UNLOCK |
631 ACPI_NS_WALK_TEMP_NODES,
Len Brown4be44fc2005-08-05 00:44:28 -0400632 acpi_ns_dump_one_object, (void *)&info,
633 NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634}
Len Brown4be44fc2005-08-05 00:44:28 -0400635#endif /* ACPI_FUTURE_USAGE */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636
637/*******************************************************************************
638 *
Robert Moore44f6c012005-04-18 22:49:35 -0400639 * FUNCTION: acpi_ns_dump_entry
640 *
641 * PARAMETERS: Handle - Node to be dumped
642 * debug_level - Output level
643 *
644 * RETURN: None
645 *
646 * DESCRIPTION: Dump a single Node
647 *
648 ******************************************************************************/
649
Len Brown4be44fc2005-08-05 00:44:28 -0400650void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
Robert Moore44f6c012005-04-18 22:49:35 -0400651{
Len Brown4be44fc2005-08-05 00:44:28 -0400652 struct acpi_walk_info info;
Robert Moore44f6c012005-04-18 22:49:35 -0400653
Len Brown4be44fc2005-08-05 00:44:28 -0400654 ACPI_FUNCTION_ENTRY();
Robert Moore44f6c012005-04-18 22:49:35 -0400655
656 info.debug_level = debug_level;
Robert Mooref9f46012005-07-08 00:00:00 -0400657 info.owner_id = ACPI_OWNER_ID_MAX;
Robert Moore44f6c012005-04-18 22:49:35 -0400658 info.display_type = ACPI_DISPLAY_SUMMARY;
659
Len Brown4be44fc2005-08-05 00:44:28 -0400660 (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
Robert Moore44f6c012005-04-18 22:49:35 -0400661}
662
Robert Moore73459f72005-06-24 00:00:00 -0400663#ifdef ACPI_ASL_COMPILER
Robert Moore44f6c012005-04-18 22:49:35 -0400664/*******************************************************************************
665 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 * FUNCTION: acpi_ns_dump_tables
667 *
668 * PARAMETERS: search_base - Root of subtree to be dumped, or
669 * NS_ALL to dump the entire namespace
670 * max_depth - Maximum depth of dump. Use INT_MAX
671 * for an effectively unlimited depth.
672 *
Robert Moore44f6c012005-04-18 22:49:35 -0400673 * RETURN: None
674 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 * DESCRIPTION: Dump the name space, or a portion of it.
676 *
677 ******************************************************************************/
678
Len Brown4be44fc2005-08-05 00:44:28 -0400679void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680{
Len Brown4be44fc2005-08-05 00:44:28 -0400681 acpi_handle search_handle = search_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682
Bob Mooreb229cf92006-04-21 17:15:00 -0400683 ACPI_FUNCTION_TRACE(ns_dump_tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684
685 if (!acpi_gbl_root_node) {
686 /*
687 * If the name space has not been initialized,
688 * there is nothing to dump.
689 */
Len Brown4be44fc2005-08-05 00:44:28 -0400690 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
691 "namespace not initialized!\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 return_VOID;
693 }
694
695 if (ACPI_NS_ALL == search_base) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400696
Robert Moore44f6c012005-04-18 22:49:35 -0400697 /* Entire namespace */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698
699 search_handle = acpi_gbl_root_node;
Len Brown4be44fc2005-08-05 00:44:28 -0400700 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 }
702
Len Brown4be44fc2005-08-05 00:44:28 -0400703 acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
704 ACPI_OWNER_ID_MAX, search_handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 return_VOID;
706}
Len Brown4be44fc2005-08-05 00:44:28 -0400707#endif /* _ACPI_ASL_COMPILER */
708#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */