blob: ce6e9732620523ba36e1a474d76dddfcf03005d9 [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 Moore25f044e2013-01-25 05:38:56 +00008 * Copyright (C) 2000 - 2013, 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"
Bob Mooree81a52b2012-12-31 00:06:50 +000047#include <acpi/acoutput.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#define _COMPONENT ACPI_NAMESPACE
Len Brown4be44fc2005-08-05 00:44:28 -040050ACPI_MODULE_NAME("nsdump")
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Robert Moore44f6c012005-04-18 22:49:35 -040052/* Local prototypes */
Robert Moore44f6c012005-04-18 22:49:35 -040053#ifdef ACPI_OBSOLETE_FUNCTIONS
Len Brown4be44fc2005-08-05 00:44:28 -040054void acpi_ns_dump_root_devices(void);
Robert Moore44f6c012005-04-18 22:49:35 -040055
56static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040057acpi_ns_dump_one_device(acpi_handle obj_handle,
58 u32 level, void *context, void **return_value);
Robert Moore44f6c012005-04-18 22:49:35 -040059#endif
60
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062/*******************************************************************************
63 *
64 * FUNCTION: acpi_ns_print_pathname
65 *
Robert Moore44f6c012005-04-18 22:49:35 -040066 * PARAMETERS: num_segments - Number of ACPI name segments
Bob Mooreba494be2012-07-12 09:40:10 +080067 * pathname - The compressed (internal) path
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 *
Robert Moore44f6c012005-04-18 22:49:35 -040069 * RETURN: None
70 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 * DESCRIPTION: Print an object's full namespace pathname
72 *
73 ******************************************************************************/
74
Len Brown4be44fc2005-08-05 00:44:28 -040075void acpi_ns_print_pathname(u32 num_segments, char *pathname)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
Bob Moore67a119f2008-06-10 13:42:13 +080077 u32 i;
Robert Moore0c9938c2005-07-29 15:15:00 -070078
Bob Mooreb229cf92006-04-21 17:15:00 -040079 ACPI_FUNCTION_NAME(ns_print_pathname);
Robert Moore0c9938c2005-07-29 15:15:00 -070080
Bob Moore10e9e752012-12-31 00:06:27 +000081 /* Check if debug output enabled */
82
83 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_NAMES, ACPI_NAMESPACE)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 return;
85 }
86
87 /* Print the entire name */
88
Len Brown4be44fc2005-08-05 00:44:28 -040089 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "["));
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91 while (num_segments) {
Robert Moore0c9938c2005-07-29 15:15:00 -070092 for (i = 0; i < 4; i++) {
Len Brown4be44fc2005-08-05 00:44:28 -040093 ACPI_IS_PRINT(pathname[i]) ?
94 acpi_os_printf("%c", pathname[i]) :
95 acpi_os_printf("?");
Robert Moore0c9938c2005-07-29 15:15:00 -070096 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Robert Moore0c9938c2005-07-29 15:15:00 -070098 pathname += ACPI_NAME_SIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 num_segments--;
100 if (num_segments) {
Len Brown4be44fc2005-08-05 00:44:28 -0400101 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 }
103 }
104
Len Brown4be44fc2005-08-05 00:44:28 -0400105 acpi_os_printf("]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106}
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108/*******************************************************************************
109 *
110 * FUNCTION: acpi_ns_dump_pathname
111 *
Bob Mooreba494be2012-07-12 09:40:10 +0800112 * PARAMETERS: handle - Object
113 * msg - Prefix message
114 * level - Desired debug level
115 * component - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 *
Robert Moore44f6c012005-04-18 22:49:35 -0400117 * RETURN: None
118 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 * DESCRIPTION: Print an object's full namespace pathname
120 * Manages allocation/freeing of a pathname buffer
121 *
122 ******************************************************************************/
123
124void
Len Brown4be44fc2005-08-05 00:44:28 -0400125acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126{
127
Bob Mooreb229cf92006-04-21 17:15:00 -0400128 ACPI_FUNCTION_TRACE(ns_dump_pathname);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
130 /* Do this only if the requested debug level and component are enabled */
131
Bob Moore10e9e752012-12-31 00:06:27 +0000132 if (!ACPI_IS_DEBUG_ENABLED(level, component)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 return_VOID;
134 }
135
136 /* Convert handle to a full pathname and print it (with supplied message) */
137
Len Brown4be44fc2005-08-05 00:44:28 -0400138 acpi_ns_print_node_pathname(handle, msg);
139 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 return_VOID;
141}
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143/*******************************************************************************
144 *
145 * FUNCTION: acpi_ns_dump_one_object
146 *
Robert Moore44f6c012005-04-18 22:49:35 -0400147 * PARAMETERS: obj_handle - Node to be dumped
Bob Mooreba494be2012-07-12 09:40:10 +0800148 * level - Nesting level of the handle
149 * context - Passed into walk_namespace
Robert Moore44f6c012005-04-18 22:49:35 -0400150 * return_value - Not used
151 *
152 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 *
154 * DESCRIPTION: Dump a single Node
155 * This procedure is a user_function called by acpi_ns_walk_namespace.
156 *
157 ******************************************************************************/
158
159acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400160acpi_ns_dump_one_object(acpi_handle obj_handle,
161 u32 level, void *context, void **return_value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162{
Len Brown4be44fc2005-08-05 00:44:28 -0400163 struct acpi_walk_info *info = (struct acpi_walk_info *)context;
164 struct acpi_namespace_node *this_node;
165 union acpi_operand_object *obj_desc = NULL;
166 acpi_object_type obj_type;
167 acpi_object_type type;
168 u32 bytes_to_dump;
169 u32 dbg_level;
170 u32 i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
Bob Mooreb229cf92006-04-21 17:15:00 -0400172 ACPI_FUNCTION_NAME(ns_dump_one_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174 /* Is output enabled? */
175
176 if (!(acpi_dbg_level & info->debug_level)) {
177 return (AE_OK);
178 }
179
180 if (!obj_handle) {
Len Brown4be44fc2005-08-05 00:44:28 -0400181 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 return (AE_OK);
183 }
184
Bob Mooref24b6642009-12-11 14:57:00 +0800185 this_node = acpi_ns_validate_handle(obj_handle);
Bob Moore4bbfb852009-02-03 14:17:29 +0800186 if (!this_node) {
187 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n",
188 obj_handle));
189 return (AE_OK);
190 }
191
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 type = this_node->type;
193
194 /* Check if the owner matches */
195
Robert Mooref9f46012005-07-08 00:00:00 -0400196 if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
Len Brown4be44fc2005-08-05 00:44:28 -0400197 (info->owner_id != this_node->owner_id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 return (AE_OK);
199 }
200
Robert Moore73459f72005-06-24 00:00:00 -0400201 if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400202
Robert Moore73459f72005-06-24 00:00:00 -0400203 /* Indent the object according to the level */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Len Brown4be44fc2005-08-05 00:44:28 -0400205 acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
Robert Moore73459f72005-06-24 00:00:00 -0400207 /* Check the node type and name */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
Robert Moore73459f72005-06-24 00:00:00 -0400209 if (type > ACPI_TYPE_LOCAL_MAX) {
Bob Mooref6a22b02010-03-05 17:56:40 +0800210 ACPI_WARNING((AE_INFO,
211 "Invalid ACPI Object Type 0x%08X", type));
Robert Moore73459f72005-06-24 00:00:00 -0400212 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
Len Brown4be44fc2005-08-05 00:44:28 -0400214 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 }
216
Bob Moored4913dc2009-03-06 10:05:18 +0800217 /* 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
Bob Moore4acb6882012-03-21 09:46:47 +0800239 /* No attached object. Some types should always have an object */
240
241 switch (type) {
242 case ACPI_TYPE_INTEGER:
243 case ACPI_TYPE_PACKAGE:
244 case ACPI_TYPE_BUFFER:
245 case ACPI_TYPE_STRING:
246 case ACPI_TYPE_METHOD:
247 acpi_os_printf("<No attached object>");
248 break;
249
250 default:
251 break;
252 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Len Brown4be44fc2005-08-05 00:44:28 -0400254 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 return (AE_OK);
256 }
257
258 switch (type) {
259 case ACPI_TYPE_PROCESSOR:
260
Bob Moore0b232fc2012-08-17 10:55:32 +0800261 acpi_os_printf("ID %02X Len %02X Addr %p\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400262 obj_desc->processor.proc_id,
263 obj_desc->processor.length,
Bob Moore1d18c052008-04-10 19:06:40 +0400264 ACPI_CAST_PTR(void,
265 obj_desc->processor.
266 address));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 break;
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 case ACPI_TYPE_DEVICE:
270
Len Brown4be44fc2005-08-05 00:44:28 -0400271 acpi_os_printf("Notify Object: %p\n", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 break;
273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 case ACPI_TYPE_METHOD:
275
Len Brown4be44fc2005-08-05 00:44:28 -0400276 acpi_os_printf("Args %X Len %.4X Aml %p\n",
277 (u32) obj_desc->method.param_count,
278 obj_desc->method.aml_length,
279 obj_desc->method.aml_start);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 break;
281
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 case ACPI_TYPE_INTEGER:
283
Len Brown4be44fc2005-08-05 00:44:28 -0400284 acpi_os_printf("= %8.8X%8.8X\n",
285 ACPI_FORMAT_UINT64(obj_desc->integer.
286 value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 break;
288
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 case ACPI_TYPE_PACKAGE:
290
291 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400292 acpi_os_printf("Elements %.2X\n",
293 obj_desc->package.count);
294 } else {
295 acpi_os_printf("[Length not yet evaluated]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 }
297 break;
298
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 case ACPI_TYPE_BUFFER:
300
301 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400302 acpi_os_printf("Len %.2X",
303 obj_desc->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
305 /* Dump some of the buffer */
306
307 if (obj_desc->buffer.length > 0) {
Len Brown4be44fc2005-08-05 00:44:28 -0400308 acpi_os_printf(" =");
309 for (i = 0;
310 (i < obj_desc->buffer.length
311 && i < 12); i++) {
312 acpi_os_printf(" %.2hX",
313 obj_desc->buffer.
314 pointer[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 }
316 }
Len Brown4be44fc2005-08-05 00:44:28 -0400317 acpi_os_printf("\n");
318 } else {
319 acpi_os_printf("[Length not yet evaluated]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 }
321 break;
322
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 case ACPI_TYPE_STRING:
324
Len Brown4be44fc2005-08-05 00:44:28 -0400325 acpi_os_printf("Len %.2X ", obj_desc->string.length);
326 acpi_ut_print_string(obj_desc->string.pointer, 32);
327 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 break;
329
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 case ACPI_TYPE_REGION:
331
Len Brown4be44fc2005-08-05 00:44:28 -0400332 acpi_os_printf("[%s]",
333 acpi_ut_get_region_name(obj_desc->region.
334 space_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400336 acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
Bob Moore1d18c052008-04-10 19:06:40 +0400337 ACPI_FORMAT_NATIVE_UINT
338 (obj_desc->region.address),
Len Brown4be44fc2005-08-05 00:44:28 -0400339 obj_desc->region.length);
340 } else {
341 acpi_os_printf
342 (" [Address/Length not yet evaluated]\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 }
344 break;
345
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 case ACPI_TYPE_LOCAL_REFERENCE:
347
Len Brown4be44fc2005-08-05 00:44:28 -0400348 acpi_os_printf("[%s]\n",
Bob Moore1044f1f2008-09-27 11:08:41 +0800349 acpi_ut_get_reference_name(obj_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 break;
351
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 case ACPI_TYPE_BUFFER_FIELD:
353
354 if (obj_desc->buffer_field.buffer_obj &&
Len Brown4be44fc2005-08-05 00:44:28 -0400355 obj_desc->buffer_field.buffer_obj->buffer.node) {
356 acpi_os_printf("Buf [%4.4s]",
357 acpi_ut_get_node_name(obj_desc->
358 buffer_field.
359 buffer_obj->
360 buffer.
361 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 }
363 break;
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 case ACPI_TYPE_LOCAL_REGION_FIELD:
366
Len Brown4be44fc2005-08-05 00:44:28 -0400367 acpi_os_printf("Rgn [%4.4s]",
368 acpi_ut_get_node_name(obj_desc->
369 common_field.
370 region_obj->region.
371 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 break;
373
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 case ACPI_TYPE_LOCAL_BANK_FIELD:
375
Len Brown4be44fc2005-08-05 00:44:28 -0400376 acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
377 acpi_ut_get_node_name(obj_desc->
378 common_field.
379 region_obj->region.
380 node),
381 acpi_ut_get_node_name(obj_desc->
382 bank_field.
383 bank_obj->
384 common_field.
385 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 break;
387
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 case ACPI_TYPE_LOCAL_INDEX_FIELD:
389
Len Brown4be44fc2005-08-05 00:44:28 -0400390 acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
391 acpi_ut_get_node_name(obj_desc->
392 index_field.
393 index_obj->
394 common_field.node),
395 acpi_ut_get_node_name(obj_desc->
396 index_field.
397 data_obj->
398 common_field.
399 node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 break;
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 case ACPI_TYPE_LOCAL_ALIAS:
403 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
404
Len Brown4be44fc2005-08-05 00:44:28 -0400405 acpi_os_printf("Target %4.4s (%p)\n",
406 acpi_ut_get_node_name(obj_desc),
407 obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 break;
409
410 default:
411
Len Brown4be44fc2005-08-05 00:44:28 -0400412 acpi_os_printf("Object %p\n", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 break;
414 }
415
416 /* Common field handling */
417
418 switch (type) {
419 case ACPI_TYPE_BUFFER_FIELD:
420 case ACPI_TYPE_LOCAL_REGION_FIELD:
421 case ACPI_TYPE_LOCAL_BANK_FIELD:
422 case ACPI_TYPE_LOCAL_INDEX_FIELD:
423
Len Brown4be44fc2005-08-05 00:44:28 -0400424 acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
425 (obj_desc->common_field.
426 base_byte_offset * 8)
427 +
428 obj_desc->common_field.
429 start_field_bit_offset,
430 obj_desc->common_field.bit_length,
431 obj_desc->common_field.
432 access_byte_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 break;
434
435 default:
436 break;
437 }
438 break;
439
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 case ACPI_DISPLAY_OBJECTS:
441
Len Brown4be44fc2005-08-05 00:44:28 -0400442 acpi_os_printf("O:%p", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 if (!obj_desc) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400444
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 /* No attached object, we are done */
446
Len Brown4be44fc2005-08-05 00:44:28 -0400447 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 return (AE_OK);
449 }
450
Bob Mooreb27d6592010-05-26 11:47:13 +0800451 acpi_os_printf("(R%u)", obj_desc->common.reference_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
453 switch (type) {
454 case ACPI_TYPE_METHOD:
455
456 /* Name is a Method and its AML offset/length are set */
457
Len Brown4be44fc2005-08-05 00:44:28 -0400458 acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start,
459 obj_desc->method.aml_length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 break;
461
462 case ACPI_TYPE_INTEGER:
463
Len Brown4be44fc2005-08-05 00:44:28 -0400464 acpi_os_printf(" I:%8.8X8.8%X\n",
465 ACPI_FORMAT_UINT64(obj_desc->integer.
466 value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 break;
468
469 case ACPI_TYPE_STRING:
470
Len Brown4be44fc2005-08-05 00:44:28 -0400471 acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
472 obj_desc->string.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 break;
474
475 case ACPI_TYPE_BUFFER:
476
Len Brown4be44fc2005-08-05 00:44:28 -0400477 acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
478 obj_desc->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 break;
480
481 default:
482
Len Brown4be44fc2005-08-05 00:44:28 -0400483 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 break;
485 }
486 break;
487
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 default:
Len Brown4be44fc2005-08-05 00:44:28 -0400489 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 break;
491 }
492
493 /* If debug turned off, done */
494
495 if (!(acpi_dbg_level & ACPI_LV_VALUES)) {
496 return (AE_OK);
497 }
498
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 /* If there is an attached object, display it */
500
Len Brown4be44fc2005-08-05 00:44:28 -0400501 dbg_level = acpi_dbg_level;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 acpi_dbg_level = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400503 obj_desc = acpi_ns_get_attached_object(this_node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 acpi_dbg_level = dbg_level;
505
506 /* Dump attached objects */
507
508 while (obj_desc) {
509 obj_type = ACPI_TYPE_INVALID;
Len Brown4be44fc2005-08-05 00:44:28 -0400510 acpi_os_printf("Attached Object %p: ", obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511
512 /* Decode the type of attached object and dump the contents */
513
Len Brown4be44fc2005-08-05 00:44:28 -0400514 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 case ACPI_DESC_TYPE_NAMED:
516
Len Brown4be44fc2005-08-05 00:44:28 -0400517 acpi_os_printf("(Ptr to Node)\n");
518 bytes_to_dump = sizeof(struct acpi_namespace_node);
519 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 break;
521
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 case ACPI_DESC_TYPE_OPERAND:
523
Bob Moore3371c192009-02-18 14:44:03 +0800524 obj_type = obj_desc->common.type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525
526 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
Len Brown4be44fc2005-08-05 00:44:28 -0400527 acpi_os_printf
Bob Moore71d993e2008-06-10 14:25:05 +0800528 ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400529 obj_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 bytes_to_dump = 32;
Len Brown4be44fc2005-08-05 00:44:28 -0400531 } else {
532 acpi_os_printf
Bob Moore71d993e2008-06-10 14:25:05 +0800533 ("(Pointer to ACPI Object type %.2X [%s])\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400534 obj_type, acpi_ut_get_type_name(obj_type));
535 bytes_to_dump =
536 sizeof(union acpi_operand_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538
Len Brown4be44fc2005-08-05 00:44:28 -0400539 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
Robert Moore6f42ccf2005-05-13 00:00:00 -0400540 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541
542 default:
543
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 break;
545 }
546
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 /* If value is NOT an internal object, we are done */
548
Len Brown4be44fc2005-08-05 00:44:28 -0400549 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
550 ACPI_DESC_TYPE_OPERAND) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 goto cleanup;
552 }
553
Bob Moored4913dc2009-03-06 10:05:18 +0800554 /* Valid object, get the pointer to next level, if any */
555
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 switch (obj_type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 case ACPI_TYPE_BUFFER:
Robert Moore6f42ccf2005-05-13 00:00:00 -0400558 case ACPI_TYPE_STRING:
559 /*
560 * NOTE: takes advantage of common fields between string/buffer
561 */
562 bytes_to_dump = obj_desc->string.length;
Len Brown4be44fc2005-08-05 00:44:28 -0400563 obj_desc = (void *)obj_desc->string.pointer;
564 acpi_os_printf("(Buffer/String pointer %p length %X)\n",
565 obj_desc, bytes_to_dump);
566 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
Robert Moore6f42ccf2005-05-13 00:00:00 -0400567 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568
569 case ACPI_TYPE_BUFFER_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400570 obj_desc =
571 (union acpi_operand_object *)obj_desc->buffer_field.
572 buffer_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 break;
574
575 case ACPI_TYPE_PACKAGE:
Len Brown4be44fc2005-08-05 00:44:28 -0400576 obj_desc = (void *)obj_desc->package.elements;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 break;
578
579 case ACPI_TYPE_METHOD:
Len Brown4be44fc2005-08-05 00:44:28 -0400580 obj_desc = (void *)obj_desc->method.aml_start;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 break;
582
583 case ACPI_TYPE_LOCAL_REGION_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400584 obj_desc = (void *)obj_desc->field.region_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 break;
586
587 case ACPI_TYPE_LOCAL_BANK_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400588 obj_desc = (void *)obj_desc->bank_field.region_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 break;
590
591 case ACPI_TYPE_LOCAL_INDEX_FIELD:
Len Brown4be44fc2005-08-05 00:44:28 -0400592 obj_desc = (void *)obj_desc->index_field.index_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 break;
594
595 default:
596 goto cleanup;
597 }
598
Len Brown4be44fc2005-08-05 00:44:28 -0400599 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 }
601
Len Brown4be44fc2005-08-05 00:44:28 -0400602 cleanup:
603 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 return (AE_OK);
605}
606
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607#ifdef ACPI_FUTURE_USAGE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608/*******************************************************************************
609 *
610 * FUNCTION: acpi_ns_dump_objects
611 *
Bob Mooreba494be2012-07-12 09:40:10 +0800612 * PARAMETERS: type - Object type to be dumped
Robert Moore44f6c012005-04-18 22:49:35 -0400613 * display_type - 0 or ACPI_DISPLAY_SUMMARY
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
615 * for an effectively unlimited depth.
Bob Moored4913dc2009-03-06 10:05:18 +0800616 * owner_id - Dump only objects owned by this ID. Use
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 * ACPI_UINT32_MAX to match all owners.
618 * start_handle - Where in namespace to start/end search
619 *
Robert Moore44f6c012005-04-18 22:49:35 -0400620 * RETURN: None
621 *
Bob Moored4913dc2009-03-06 10:05:18 +0800622 * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
623 * acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 *
625 ******************************************************************************/
626
627void
Len Brown4be44fc2005-08-05 00:44:28 -0400628acpi_ns_dump_objects(acpi_object_type type,
629 u8 display_type,
630 u32 max_depth,
631 acpi_owner_id owner_id, acpi_handle start_handle)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632{
Len Brown4be44fc2005-08-05 00:44:28 -0400633 struct acpi_walk_info info;
Bob Moore672af842011-01-12 09:13:31 +0800634 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635
Len Brown4be44fc2005-08-05 00:44:28 -0400636 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637
Bob Moore672af842011-01-12 09:13:31 +0800638 /*
639 * Just lock the entire namespace for the duration of the dump.
640 * We don't want any changes to the namespace during this time,
641 * especially the temporary nodes since we are going to display
642 * them also.
643 */
644 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
645 if (ACPI_FAILURE(status)) {
646 acpi_os_printf("Could not acquire namespace mutex\n");
647 return;
648 }
649
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 info.debug_level = ACPI_LV_TABLES;
651 info.owner_id = owner_id;
652 info.display_type = display_type;
653
Len Brown4be44fc2005-08-05 00:44:28 -0400654 (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
Bob Moored1fdda832007-02-02 19:48:21 +0300655 ACPI_NS_WALK_NO_UNLOCK |
656 ACPI_NS_WALK_TEMP_NODES,
Lin Ming22635762009-11-13 10:06:08 +0800657 acpi_ns_dump_one_object, NULL,
658 (void *)&info, NULL);
Bob Moore672af842011-01-12 09:13:31 +0800659
660 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661}
Len Brown4be44fc2005-08-05 00:44:28 -0400662#endif /* ACPI_FUTURE_USAGE */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663
664/*******************************************************************************
665 *
Robert Moore44f6c012005-04-18 22:49:35 -0400666 * FUNCTION: acpi_ns_dump_entry
667 *
Bob Mooreba494be2012-07-12 09:40:10 +0800668 * PARAMETERS: handle - Node to be dumped
Robert Moore44f6c012005-04-18 22:49:35 -0400669 * debug_level - Output level
670 *
671 * RETURN: None
672 *
673 * DESCRIPTION: Dump a single Node
674 *
675 ******************************************************************************/
676
Len Brown4be44fc2005-08-05 00:44:28 -0400677void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
Robert Moore44f6c012005-04-18 22:49:35 -0400678{
Len Brown4be44fc2005-08-05 00:44:28 -0400679 struct acpi_walk_info info;
Robert Moore44f6c012005-04-18 22:49:35 -0400680
Len Brown4be44fc2005-08-05 00:44:28 -0400681 ACPI_FUNCTION_ENTRY();
Robert Moore44f6c012005-04-18 22:49:35 -0400682
683 info.debug_level = debug_level;
Robert Mooref9f46012005-07-08 00:00:00 -0400684 info.owner_id = ACPI_OWNER_ID_MAX;
Robert Moore44f6c012005-04-18 22:49:35 -0400685 info.display_type = ACPI_DISPLAY_SUMMARY;
686
Len Brown4be44fc2005-08-05 00:44:28 -0400687 (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
Robert Moore44f6c012005-04-18 22:49:35 -0400688}
689
Robert Moore73459f72005-06-24 00:00:00 -0400690#ifdef ACPI_ASL_COMPILER
Robert Moore44f6c012005-04-18 22:49:35 -0400691/*******************************************************************************
692 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 * FUNCTION: acpi_ns_dump_tables
694 *
695 * PARAMETERS: search_base - Root of subtree to be dumped, or
696 * NS_ALL to dump the entire namespace
Bob Moore73a30902012-10-31 02:26:55 +0000697 * max_depth - Maximum depth of dump. Use INT_MAX
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 * for an effectively unlimited depth.
699 *
Robert Moore44f6c012005-04-18 22:49:35 -0400700 * RETURN: None
701 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 * DESCRIPTION: Dump the name space, or a portion of it.
703 *
704 ******************************************************************************/
705
Len Brown4be44fc2005-08-05 00:44:28 -0400706void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707{
Len Brown4be44fc2005-08-05 00:44:28 -0400708 acpi_handle search_handle = search_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709
Bob Mooreb229cf92006-04-21 17:15:00 -0400710 ACPI_FUNCTION_TRACE(ns_dump_tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711
712 if (!acpi_gbl_root_node) {
713 /*
714 * If the name space has not been initialized,
715 * there is nothing to dump.
716 */
Len Brown4be44fc2005-08-05 00:44:28 -0400717 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
718 "namespace not initialized!\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 return_VOID;
720 }
721
722 if (ACPI_NS_ALL == search_base) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400723
Robert Moore44f6c012005-04-18 22:49:35 -0400724 /* Entire namespace */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725
726 search_handle = acpi_gbl_root_node;
Len Brown4be44fc2005-08-05 00:44:28 -0400727 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "\\\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 }
729
Len Brown4be44fc2005-08-05 00:44:28 -0400730 acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
731 ACPI_OWNER_ID_MAX, search_handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 return_VOID;
733}
Lv Zheng75c80442012-12-19 05:36:49 +0000734#endif
735#endif