blob: 3e048794405d85da4d2ae106f177c16997bb3d54 [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/*
Bob Moore77848132012-01-12 13:27:23 +08008 * Copyright (C) 2000 - 2012, 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>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acnamesp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define _COMPONENT ACPI_NAMESPACE
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("nsdump")
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Robert Moore44f6c012005-04-18 22:49:35 -040051/* Local prototypes */
Robert Moore44f6c012005-04-18 22:49:35 -040052#ifdef ACPI_OBSOLETE_FUNCTIONS
Len Brown4be44fc2005-08-05 00:44:28 -040053void acpi_ns_dump_root_devices(void);
Robert Moore44f6c012005-04-18 22:49:35 -040054
55static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040056acpi_ns_dump_one_device(acpi_handle obj_handle,
57 u32 level, void *context, void **return_value);
Robert Moore44f6c012005-04-18 22:49:35 -040058#endif
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061/*******************************************************************************
62 *
63 * FUNCTION: acpi_ns_print_pathname
64 *
Robert Moore44f6c012005-04-18 22:49:35 -040065 * PARAMETERS: num_segments - Number of ACPI name segments
Bob Mooreba494be2012-07-12 09:40:10 +080066 * pathname - The compressed (internal) path
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 *
Robert Moore44f6c012005-04-18 22:49:35 -040068 * RETURN: None
69 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 * DESCRIPTION: Print an object's full namespace pathname
71 *
72 ******************************************************************************/
73
Len Brown4be44fc2005-08-05 00:44:28 -040074void acpi_ns_print_pathname(u32 num_segments, char *pathname)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075{
Bob Moore67a119f2008-06-10 13:42:13 +080076 u32 i;
Robert Moore0c9938c2005-07-29 15:15:00 -070077
Bob Mooreb229cf92006-04-21 17:15:00 -040078 ACPI_FUNCTION_NAME(ns_print_pathname);
Robert Moore0c9938c2005-07-29 15:15:00 -070079
Bob Moore10e9e752012-12-31 00:06:27 +000080 /* Check if debug output enabled */
81
82 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_NAMES, ACPI_NAMESPACE)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 return;
84 }
85
86 /* Print the entire name */
87
Len Brown4be44fc2005-08-05 00:44:28 -040088 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "["));
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90 while (num_segments) {
Robert Moore0c9938c2005-07-29 15:15:00 -070091 for (i = 0; i < 4; i++) {
Len Brown4be44fc2005-08-05 00:44:28 -040092 ACPI_IS_PRINT(pathname[i]) ?
93 acpi_os_printf("%c", pathname[i]) :
94 acpi_os_printf("?");
Robert Moore0c9938c2005-07-29 15:15:00 -070095 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
Robert Moore0c9938c2005-07-29 15:15:00 -070097 pathname += ACPI_NAME_SIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 num_segments--;
99 if (num_segments) {
Len Brown4be44fc2005-08-05 00:44:28 -0400100 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 }
102 }
103
Len Brown4be44fc2005-08-05 00:44:28 -0400104 acpi_os_printf("]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105}
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107/*******************************************************************************
108 *
109 * FUNCTION: acpi_ns_dump_pathname
110 *
Bob Mooreba494be2012-07-12 09:40:10 +0800111 * PARAMETERS: handle - Object
112 * msg - Prefix message
113 * level - Desired debug level
114 * component - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 *
Robert Moore44f6c012005-04-18 22:49:35 -0400116 * RETURN: None
117 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 * DESCRIPTION: Print an object's full namespace pathname
119 * Manages allocation/freeing of a pathname buffer
120 *
121 ******************************************************************************/
122
123void
Len Brown4be44fc2005-08-05 00:44:28 -0400124acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125{
126
Bob Mooreb229cf92006-04-21 17:15:00 -0400127 ACPI_FUNCTION_TRACE(ns_dump_pathname);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129 /* Do this only if the requested debug level and component are enabled */
130
Bob Moore10e9e752012-12-31 00:06:27 +0000131 if (!ACPI_IS_DEBUG_ENABLED(level, component)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 return_VOID;
133 }
134
135 /* Convert handle to a full pathname and print it (with supplied message) */
136
Len Brown4be44fc2005-08-05 00:44:28 -0400137 acpi_ns_print_node_pathname(handle, msg);
138 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 return_VOID;
140}
141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142/*******************************************************************************
143 *
144 * FUNCTION: acpi_ns_dump_one_object
145 *
Robert Moore44f6c012005-04-18 22:49:35 -0400146 * PARAMETERS: obj_handle - Node to be dumped
Bob Mooreba494be2012-07-12 09:40:10 +0800147 * level - Nesting level of the handle
148 * context - Passed into walk_namespace
Robert Moore44f6c012005-04-18 22:49:35 -0400149 * return_value - Not used
150 *
151 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 *
153 * DESCRIPTION: Dump a single Node
154 * This procedure is a user_function called by acpi_ns_walk_namespace.
155 *
156 ******************************************************************************/
157
158acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400159acpi_ns_dump_one_object(acpi_handle obj_handle,
160 u32 level, void *context, void **return_value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161{
Len Brown4be44fc2005-08-05 00:44:28 -0400162 struct acpi_walk_info *info = (struct acpi_walk_info *)context;
163 struct acpi_namespace_node *this_node;
164 union acpi_operand_object *obj_desc = NULL;
165 acpi_object_type obj_type;
166 acpi_object_type type;
167 u32 bytes_to_dump;
168 u32 dbg_level;
169 u32 i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Bob Mooreb229cf92006-04-21 17:15:00 -0400171 ACPI_FUNCTION_NAME(ns_dump_one_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
173 /* Is output enabled? */
174
175 if (!(acpi_dbg_level & info->debug_level)) {
176 return (AE_OK);
177 }
178
179 if (!obj_handle) {
Len Brown4be44fc2005-08-05 00:44:28 -0400180 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 return (AE_OK);
182 }
183
Bob Mooref24b6642009-12-11 14:57:00 +0800184 this_node = acpi_ns_validate_handle(obj_handle);
Bob Moore4bbfb852009-02-03 14:17:29 +0800185 if (!this_node) {
186 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n",
187 obj_handle));
188 return (AE_OK);
189 }
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 type = this_node->type;
192
193 /* Check if the owner matches */
194
Robert Mooref9f46012005-07-08 00:00:00 -0400195 if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
Len Brown4be44fc2005-08-05 00:44:28 -0400196 (info->owner_id != this_node->owner_id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 return (AE_OK);
198 }
199
Robert Moore73459f72005-06-24 00:00:00 -0400200 if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400201
Robert Moore73459f72005-06-24 00:00:00 -0400202 /* Indent the object according to the level */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
Len Brown4be44fc2005-08-05 00:44:28 -0400204 acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
Robert Moore73459f72005-06-24 00:00:00 -0400206 /* Check the node type and name */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
Robert Moore73459f72005-06-24 00:00:00 -0400208 if (type > ACPI_TYPE_LOCAL_MAX) {
Bob Mooref6a22b02010-03-05 17:56:40 +0800209 ACPI_WARNING((AE_INFO,
210 "Invalid ACPI Object Type 0x%08X", type));
Robert Moore73459f72005-06-24 00:00:00 -0400211 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
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
Bob Moored4913dc2009-03-06 10:05:18 +0800216 /* Now we can print out the pertinent information */
217
Bob Moore28f55eb2005-12-02 18:27:00 -0500218 acpi_os_printf(" %-12s %p %2.2X ",
219 acpi_ut_get_type_name(type), this_node,
220 this_node->owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222 dbg_level = acpi_dbg_level;
223 acpi_dbg_level = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400224 obj_desc = acpi_ns_get_attached_object(this_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 acpi_dbg_level = dbg_level;
226
Bob Moored1fdda832007-02-02 19:48:21 +0300227 /* Temp nodes are those nodes created by a control method */
228
229 if (this_node->flags & ANOBJ_TEMPORARY) {
230 acpi_os_printf("(T) ");
231 }
232
Robert Moore73459f72005-06-24 00:00:00 -0400233 switch (info->display_type & ACPI_DISPLAY_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 case ACPI_DISPLAY_SUMMARY:
235
236 if (!obj_desc) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400237
Bob Moore4acb6882012-03-21 09:46:47 +0800238 /* No attached object. Some types should always have an object */
239
240 switch (type) {
241 case ACPI_TYPE_INTEGER:
242 case ACPI_TYPE_PACKAGE:
243 case ACPI_TYPE_BUFFER:
244 case ACPI_TYPE_STRING:
245 case ACPI_TYPE_METHOD:
246 acpi_os_printf("<No attached object>");
247 break;
248
249 default:
250 break;
251 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
Len Brown4be44fc2005-08-05 00:44:28 -0400253 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 return (AE_OK);
255 }
256
257 switch (type) {
258 case ACPI_TYPE_PROCESSOR:
259
Bob Moore0b232fc2012-08-17 10:55:32 +0800260 acpi_os_printf("ID %02X Len %02X Addr %p\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400261 obj_desc->processor.proc_id,
262 obj_desc->processor.length,
Bob Moore1d18c052008-04-10 19:06:40 +0400263 ACPI_CAST_PTR(void,
264 obj_desc->processor.
265 address));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 break;
267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 case ACPI_TYPE_DEVICE:
269
Len Brown4be44fc2005-08-05 00:44:28 -0400270 acpi_os_printf("Notify Object: %p\n", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 break;
272
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 case ACPI_TYPE_METHOD:
274
Len Brown4be44fc2005-08-05 00:44:28 -0400275 acpi_os_printf("Args %X Len %.4X Aml %p\n",
276 (u32) obj_desc->method.param_count,
277 obj_desc->method.aml_length,
278 obj_desc->method.aml_start);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 break;
280
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 case ACPI_TYPE_INTEGER:
282
Len Brown4be44fc2005-08-05 00:44:28 -0400283 acpi_os_printf("= %8.8X%8.8X\n",
284 ACPI_FORMAT_UINT64(obj_desc->integer.
285 value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 break;
287
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 case ACPI_TYPE_PACKAGE:
289
290 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400291 acpi_os_printf("Elements %.2X\n",
292 obj_desc->package.count);
293 } else {
294 acpi_os_printf("[Length not yet evaluated]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 }
296 break;
297
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 case ACPI_TYPE_BUFFER:
299
300 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400301 acpi_os_printf("Len %.2X",
302 obj_desc->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
304 /* Dump some of the buffer */
305
306 if (obj_desc->buffer.length > 0) {
Len Brown4be44fc2005-08-05 00:44:28 -0400307 acpi_os_printf(" =");
308 for (i = 0;
309 (i < obj_desc->buffer.length
310 && i < 12); i++) {
311 acpi_os_printf(" %.2hX",
312 obj_desc->buffer.
313 pointer[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 }
315 }
Len Brown4be44fc2005-08-05 00:44:28 -0400316 acpi_os_printf("\n");
317 } else {
318 acpi_os_printf("[Length not yet evaluated]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 }
320 break;
321
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 case ACPI_TYPE_STRING:
323
Len Brown4be44fc2005-08-05 00:44:28 -0400324 acpi_os_printf("Len %.2X ", obj_desc->string.length);
325 acpi_ut_print_string(obj_desc->string.pointer, 32);
326 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 break;
328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 case ACPI_TYPE_REGION:
330
Len Brown4be44fc2005-08-05 00:44:28 -0400331 acpi_os_printf("[%s]",
332 acpi_ut_get_region_name(obj_desc->region.
333 space_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400335 acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
Bob Moore1d18c052008-04-10 19:06:40 +0400336 ACPI_FORMAT_NATIVE_UINT
337 (obj_desc->region.address),
Len Brown4be44fc2005-08-05 00:44:28 -0400338 obj_desc->region.length);
339 } else {
340 acpi_os_printf
341 (" [Address/Length not yet evaluated]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 }
343 break;
344
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 case ACPI_TYPE_LOCAL_REFERENCE:
346
Len Brown4be44fc2005-08-05 00:44:28 -0400347 acpi_os_printf("[%s]\n",
Bob Moore1044f1f2008-09-27 11:08:41 +0800348 acpi_ut_get_reference_name(obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 break;
350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 case ACPI_TYPE_BUFFER_FIELD:
352
353 if (obj_desc->buffer_field.buffer_obj &&
Len Brown4be44fc2005-08-05 00:44:28 -0400354 obj_desc->buffer_field.buffer_obj->buffer.node) {
355 acpi_os_printf("Buf [%4.4s]",
356 acpi_ut_get_node_name(obj_desc->
357 buffer_field.
358 buffer_obj->
359 buffer.
360 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 }
362 break;
363
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 case ACPI_TYPE_LOCAL_REGION_FIELD:
365
Len Brown4be44fc2005-08-05 00:44:28 -0400366 acpi_os_printf("Rgn [%4.4s]",
367 acpi_ut_get_node_name(obj_desc->
368 common_field.
369 region_obj->region.
370 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 break;
372
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 case ACPI_TYPE_LOCAL_BANK_FIELD:
374
Len Brown4be44fc2005-08-05 00:44:28 -0400375 acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
376 acpi_ut_get_node_name(obj_desc->
377 common_field.
378 region_obj->region.
379 node),
380 acpi_ut_get_node_name(obj_desc->
381 bank_field.
382 bank_obj->
383 common_field.
384 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 break;
386
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 case ACPI_TYPE_LOCAL_INDEX_FIELD:
388
Len Brown4be44fc2005-08-05 00:44:28 -0400389 acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
390 acpi_ut_get_node_name(obj_desc->
391 index_field.
392 index_obj->
393 common_field.node),
394 acpi_ut_get_node_name(obj_desc->
395 index_field.
396 data_obj->
397 common_field.
398 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 break;
400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 case ACPI_TYPE_LOCAL_ALIAS:
402 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
403
Len Brown4be44fc2005-08-05 00:44:28 -0400404 acpi_os_printf("Target %4.4s (%p)\n",
405 acpi_ut_get_node_name(obj_desc),
406 obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 break;
408
409 default:
410
Len Brown4be44fc2005-08-05 00:44:28 -0400411 acpi_os_printf("Object %p\n", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 break;
413 }
414
415 /* Common field handling */
416
417 switch (type) {
418 case ACPI_TYPE_BUFFER_FIELD:
419 case ACPI_TYPE_LOCAL_REGION_FIELD:
420 case ACPI_TYPE_LOCAL_BANK_FIELD:
421 case ACPI_TYPE_LOCAL_INDEX_FIELD:
422
Len Brown4be44fc2005-08-05 00:44:28 -0400423 acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
424 (obj_desc->common_field.
425 base_byte_offset * 8)
426 +
427 obj_desc->common_field.
428 start_field_bit_offset,
429 obj_desc->common_field.bit_length,
430 obj_desc->common_field.
431 access_byte_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 break;
433
434 default:
435 break;
436 }
437 break;
438
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 case ACPI_DISPLAY_OBJECTS:
440
Len Brown4be44fc2005-08-05 00:44:28 -0400441 acpi_os_printf("O:%p", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 if (!obj_desc) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400443
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 /* No attached object, we are done */
445
Len Brown4be44fc2005-08-05 00:44:28 -0400446 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 return (AE_OK);
448 }
449
Bob Mooreb27d6592010-05-26 11:47:13 +0800450 acpi_os_printf("(R%u)", obj_desc->common.reference_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451
452 switch (type) {
453 case ACPI_TYPE_METHOD:
454
455 /* Name is a Method and its AML offset/length are set */
456
Len Brown4be44fc2005-08-05 00:44:28 -0400457 acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start,
458 obj_desc->method.aml_length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 break;
460
461 case ACPI_TYPE_INTEGER:
462
Len Brown4be44fc2005-08-05 00:44:28 -0400463 acpi_os_printf(" I:%8.8X8.8%X\n",
464 ACPI_FORMAT_UINT64(obj_desc->integer.
465 value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 break;
467
468 case ACPI_TYPE_STRING:
469
Len Brown4be44fc2005-08-05 00:44:28 -0400470 acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
471 obj_desc->string.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 break;
473
474 case ACPI_TYPE_BUFFER:
475
Len Brown4be44fc2005-08-05 00:44:28 -0400476 acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
477 obj_desc->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 break;
479
480 default:
481
Len Brown4be44fc2005-08-05 00:44:28 -0400482 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 break;
484 }
485 break;
486
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 default:
Len Brown4be44fc2005-08-05 00:44:28 -0400488 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 break;
490 }
491
492 /* If debug turned off, done */
493
494 if (!(acpi_dbg_level & ACPI_LV_VALUES)) {
495 return (AE_OK);
496 }
497
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 /* If there is an attached object, display it */
499
Len Brown4be44fc2005-08-05 00:44:28 -0400500 dbg_level = acpi_dbg_level;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 acpi_dbg_level = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400502 obj_desc = acpi_ns_get_attached_object(this_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 acpi_dbg_level = dbg_level;
504
505 /* Dump attached objects */
506
507 while (obj_desc) {
508 obj_type = ACPI_TYPE_INVALID;
Len Brown4be44fc2005-08-05 00:44:28 -0400509 acpi_os_printf("Attached Object %p: ", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510
511 /* Decode the type of attached object and dump the contents */
512
Len Brown4be44fc2005-08-05 00:44:28 -0400513 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 case ACPI_DESC_TYPE_NAMED:
515
Len Brown4be44fc2005-08-05 00:44:28 -0400516 acpi_os_printf("(Ptr to Node)\n");
517 bytes_to_dump = sizeof(struct acpi_namespace_node);
518 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 break;
520
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 case ACPI_DESC_TYPE_OPERAND:
522
Bob Moore3371c192009-02-18 14:44:03 +0800523 obj_type = obj_desc->common.type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524
525 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
Len Brown4be44fc2005-08-05 00:44:28 -0400526 acpi_os_printf
Bob Moore71d993e2008-06-10 14:25:05 +0800527 ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400528 obj_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 bytes_to_dump = 32;
Len Brown4be44fc2005-08-05 00:44:28 -0400530 } else {
531 acpi_os_printf
Bob Moore71d993e2008-06-10 14:25:05 +0800532 ("(Pointer to ACPI Object type %.2X [%s])\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400533 obj_type, acpi_ut_get_type_name(obj_type));
534 bytes_to_dump =
535 sizeof(union acpi_operand_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537
Len Brown4be44fc2005-08-05 00:44:28 -0400538 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
Robert Moore6f42ccf2005-05-13 00:00:00 -0400539 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540
541 default:
542
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 break;
544 }
545
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 /* If value is NOT an internal object, we are done */
547
Len Brown4be44fc2005-08-05 00:44:28 -0400548 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
549 ACPI_DESC_TYPE_OPERAND) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 goto cleanup;
551 }
552
Bob Moored4913dc2009-03-06 10:05:18 +0800553 /* Valid object, get the pointer to next level, if any */
554
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 switch (obj_type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 case ACPI_TYPE_BUFFER:
Robert Moore6f42ccf2005-05-13 00:00:00 -0400557 case ACPI_TYPE_STRING:
558 /*
559 * NOTE: takes advantage of common fields between string/buffer
560 */
561 bytes_to_dump = obj_desc->string.length;
Len Brown4be44fc2005-08-05 00:44:28 -0400562 obj_desc = (void *)obj_desc->string.pointer;
563 acpi_os_printf("(Buffer/String pointer %p length %X)\n",
564 obj_desc, bytes_to_dump);
565 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
Robert Moore6f42ccf2005-05-13 00:00:00 -0400566 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567
568 case ACPI_TYPE_BUFFER_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400569 obj_desc =
570 (union acpi_operand_object *)obj_desc->buffer_field.
571 buffer_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 break;
573
574 case ACPI_TYPE_PACKAGE:
Len Brown4be44fc2005-08-05 00:44:28 -0400575 obj_desc = (void *)obj_desc->package.elements;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 break;
577
578 case ACPI_TYPE_METHOD:
Len Brown4be44fc2005-08-05 00:44:28 -0400579 obj_desc = (void *)obj_desc->method.aml_start;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 break;
581
582 case ACPI_TYPE_LOCAL_REGION_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400583 obj_desc = (void *)obj_desc->field.region_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 break;
585
586 case ACPI_TYPE_LOCAL_BANK_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400587 obj_desc = (void *)obj_desc->bank_field.region_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 break;
589
590 case ACPI_TYPE_LOCAL_INDEX_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400591 obj_desc = (void *)obj_desc->index_field.index_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 break;
593
594 default:
595 goto cleanup;
596 }
597
Len Brown4be44fc2005-08-05 00:44:28 -0400598 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 }
600
Len Brown4be44fc2005-08-05 00:44:28 -0400601 cleanup:
602 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 return (AE_OK);
604}
605
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606#ifdef ACPI_FUTURE_USAGE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607/*******************************************************************************
608 *
609 * FUNCTION: acpi_ns_dump_objects
610 *
Bob Mooreba494be2012-07-12 09:40:10 +0800611 * PARAMETERS: type - Object type to be dumped
Robert Moore44f6c012005-04-18 22:49:35 -0400612 * display_type - 0 or ACPI_DISPLAY_SUMMARY
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
614 * for an effectively unlimited depth.
Bob Moored4913dc2009-03-06 10:05:18 +0800615 * owner_id - Dump only objects owned by this ID. Use
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 * ACPI_UINT32_MAX to match all owners.
617 * start_handle - Where in namespace to start/end search
618 *
Robert Moore44f6c012005-04-18 22:49:35 -0400619 * RETURN: None
620 *
Bob Moored4913dc2009-03-06 10:05:18 +0800621 * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
622 * acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 *
624 ******************************************************************************/
625
626void
Len Brown4be44fc2005-08-05 00:44:28 -0400627acpi_ns_dump_objects(acpi_object_type type,
628 u8 display_type,
629 u32 max_depth,
630 acpi_owner_id owner_id, acpi_handle start_handle)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631{
Len Brown4be44fc2005-08-05 00:44:28 -0400632 struct acpi_walk_info info;
Bob Moore672af842011-01-12 09:13:31 +0800633 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634
Len Brown4be44fc2005-08-05 00:44:28 -0400635 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636
Bob Moore672af842011-01-12 09:13:31 +0800637 /*
638 * Just lock the entire namespace for the duration of the dump.
639 * We don't want any changes to the namespace during this time,
640 * especially the temporary nodes since we are going to display
641 * them also.
642 */
643 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
644 if (ACPI_FAILURE(status)) {
645 acpi_os_printf("Could not acquire namespace mutex\n");
646 return;
647 }
648
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 info.debug_level = ACPI_LV_TABLES;
650 info.owner_id = owner_id;
651 info.display_type = display_type;
652
Len Brown4be44fc2005-08-05 00:44:28 -0400653 (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
Bob Moored1fdda832007-02-02 19:48:21 +0300654 ACPI_NS_WALK_NO_UNLOCK |
655 ACPI_NS_WALK_TEMP_NODES,
Lin Ming22635762009-11-13 10:06:08 +0800656 acpi_ns_dump_one_object, NULL,
657 (void *)&info, NULL);
Bob Moore672af842011-01-12 09:13:31 +0800658
659 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660}
Len Brown4be44fc2005-08-05 00:44:28 -0400661#endif /* ACPI_FUTURE_USAGE */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662
663/*******************************************************************************
664 *
Robert Moore44f6c012005-04-18 22:49:35 -0400665 * FUNCTION: acpi_ns_dump_entry
666 *
Bob Mooreba494be2012-07-12 09:40:10 +0800667 * PARAMETERS: handle - Node to be dumped
Robert Moore44f6c012005-04-18 22:49:35 -0400668 * debug_level - Output level
669 *
670 * RETURN: None
671 *
672 * DESCRIPTION: Dump a single Node
673 *
674 ******************************************************************************/
675
Len Brown4be44fc2005-08-05 00:44:28 -0400676void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
Robert Moore44f6c012005-04-18 22:49:35 -0400677{
Len Brown4be44fc2005-08-05 00:44:28 -0400678 struct acpi_walk_info info;
Robert Moore44f6c012005-04-18 22:49:35 -0400679
Len Brown4be44fc2005-08-05 00:44:28 -0400680 ACPI_FUNCTION_ENTRY();
Robert Moore44f6c012005-04-18 22:49:35 -0400681
682 info.debug_level = debug_level;
Robert Mooref9f46012005-07-08 00:00:00 -0400683 info.owner_id = ACPI_OWNER_ID_MAX;
Robert Moore44f6c012005-04-18 22:49:35 -0400684 info.display_type = ACPI_DISPLAY_SUMMARY;
685
Len Brown4be44fc2005-08-05 00:44:28 -0400686 (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
Robert Moore44f6c012005-04-18 22:49:35 -0400687}
688
Robert Moore73459f72005-06-24 00:00:00 -0400689#ifdef ACPI_ASL_COMPILER
Robert Moore44f6c012005-04-18 22:49:35 -0400690/*******************************************************************************
691 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 * FUNCTION: acpi_ns_dump_tables
693 *
694 * PARAMETERS: search_base - Root of subtree to be dumped, or
695 * NS_ALL to dump the entire namespace
Bob Moore73a30902012-10-31 02:26:55 +0000696 * max_depth - Maximum depth of dump. Use INT_MAX
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 * for an effectively unlimited depth.
698 *
Robert Moore44f6c012005-04-18 22:49:35 -0400699 * RETURN: None
700 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 * DESCRIPTION: Dump the name space, or a portion of it.
702 *
703 ******************************************************************************/
704
Len Brown4be44fc2005-08-05 00:44:28 -0400705void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706{
Len Brown4be44fc2005-08-05 00:44:28 -0400707 acpi_handle search_handle = search_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708
Bob Mooreb229cf92006-04-21 17:15:00 -0400709 ACPI_FUNCTION_TRACE(ns_dump_tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710
711 if (!acpi_gbl_root_node) {
712 /*
713 * If the name space has not been initialized,
714 * there is nothing to dump.
715 */
Len Brown4be44fc2005-08-05 00:44:28 -0400716 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
717 "namespace not initialized!\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 return_VOID;
719 }
720
721 if (ACPI_NS_ALL == search_base) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400722
Robert Moore44f6c012005-04-18 22:49:35 -0400723 /* Entire namespace */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724
725 search_handle = acpi_gbl_root_node;
Len Brown4be44fc2005-08-05 00:44:28 -0400726 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 }
728
Len Brown4be44fc2005-08-05 00:44:28 -0400729 acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
730 ACPI_OWNER_ID_MAX, search_handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 return_VOID;
732}
Lv Zheng75c80442012-12-19 05:36:49 +0000733#endif
734#endif