Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: nsdump - table dumping routines for debug |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
| 8 | * Copyright (C) 2000 - 2005, R. Byron Moore |
| 9 | * 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 | |
| 44 | |
| 45 | #include <acpi/acpi.h> |
| 46 | #include <acpi/acnamesp.h> |
| 47 | #include <acpi/acparser.h> |
| 48 | |
| 49 | |
| 50 | #define _COMPONENT ACPI_NAMESPACE |
| 51 | ACPI_MODULE_NAME ("nsdump") |
| 52 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 53 | /* Local prototypes */ |
| 54 | |
| 55 | #ifdef ACPI_OBSOLETE_FUNCTIONS |
| 56 | void |
| 57 | acpi_ns_dump_root_devices ( |
| 58 | void); |
| 59 | |
| 60 | static acpi_status |
| 61 | acpi_ns_dump_one_device ( |
| 62 | acpi_handle obj_handle, |
| 63 | u32 level, |
| 64 | void *context, |
| 65 | void **return_value); |
| 66 | #endif |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | /******************************************************************************* |
| 71 | * |
| 72 | * FUNCTION: acpi_ns_print_pathname |
| 73 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 74 | * PARAMETERS: num_segments - Number of ACPI name segments |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | * Pathname - The compressed (internal) path |
| 76 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 77 | * RETURN: None |
| 78 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | * DESCRIPTION: Print an object's full namespace pathname |
| 80 | * |
| 81 | ******************************************************************************/ |
| 82 | |
| 83 | void |
| 84 | acpi_ns_print_pathname ( |
| 85 | u32 num_segments, |
| 86 | char *pathname) |
| 87 | { |
| 88 | ACPI_FUNCTION_NAME ("ns_print_pathname"); |
| 89 | |
| 90 | |
| 91 | if (!(acpi_dbg_level & ACPI_LV_NAMES) || !(acpi_dbg_layer & ACPI_NAMESPACE)) { |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | /* Print the entire name */ |
| 96 | |
| 97 | ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); |
| 98 | |
| 99 | while (num_segments) { |
| 100 | acpi_os_printf ("%4.4s", pathname); |
| 101 | pathname += ACPI_NAME_SIZE; |
| 102 | |
| 103 | num_segments--; |
| 104 | if (num_segments) { |
| 105 | acpi_os_printf ("."); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | acpi_os_printf ("]\n"); |
| 110 | } |
| 111 | |
| 112 | |
| 113 | /******************************************************************************* |
| 114 | * |
| 115 | * FUNCTION: acpi_ns_dump_pathname |
| 116 | * |
| 117 | * PARAMETERS: Handle - Object |
| 118 | * Msg - Prefix message |
| 119 | * Level - Desired debug level |
| 120 | * Component - Caller's component ID |
| 121 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 122 | * RETURN: None |
| 123 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | * DESCRIPTION: Print an object's full namespace pathname |
| 125 | * Manages allocation/freeing of a pathname buffer |
| 126 | * |
| 127 | ******************************************************************************/ |
| 128 | |
| 129 | void |
| 130 | acpi_ns_dump_pathname ( |
| 131 | acpi_handle handle, |
| 132 | char *msg, |
| 133 | u32 level, |
| 134 | u32 component) |
| 135 | { |
| 136 | |
| 137 | ACPI_FUNCTION_TRACE ("ns_dump_pathname"); |
| 138 | |
| 139 | |
| 140 | /* Do this only if the requested debug level and component are enabled */ |
| 141 | |
| 142 | if (!(acpi_dbg_level & level) || !(acpi_dbg_layer & component)) { |
| 143 | return_VOID; |
| 144 | } |
| 145 | |
| 146 | /* Convert handle to a full pathname and print it (with supplied message) */ |
| 147 | |
| 148 | acpi_ns_print_node_pathname (handle, msg); |
| 149 | acpi_os_printf ("\n"); |
| 150 | return_VOID; |
| 151 | } |
| 152 | |
| 153 | |
| 154 | /******************************************************************************* |
| 155 | * |
| 156 | * FUNCTION: acpi_ns_dump_one_object |
| 157 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 158 | * PARAMETERS: obj_handle - Node to be dumped |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | * Level - Nesting level of the handle |
| 160 | * Context - Passed into walk_namespace |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 161 | * return_value - Not used |
| 162 | * |
| 163 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | * |
| 165 | * DESCRIPTION: Dump a single Node |
| 166 | * This procedure is a user_function called by acpi_ns_walk_namespace. |
| 167 | * |
| 168 | ******************************************************************************/ |
| 169 | |
| 170 | acpi_status |
| 171 | acpi_ns_dump_one_object ( |
| 172 | acpi_handle obj_handle, |
| 173 | u32 level, |
| 174 | void *context, |
| 175 | void **return_value) |
| 176 | { |
| 177 | struct acpi_walk_info *info = (struct acpi_walk_info *) context; |
| 178 | struct acpi_namespace_node *this_node; |
| 179 | union acpi_operand_object *obj_desc = NULL; |
| 180 | acpi_object_type obj_type; |
| 181 | acpi_object_type type; |
| 182 | u32 bytes_to_dump; |
| 183 | u32 dbg_level; |
| 184 | u32 i; |
| 185 | |
| 186 | |
| 187 | ACPI_FUNCTION_NAME ("ns_dump_one_object"); |
| 188 | |
| 189 | |
| 190 | /* Is output enabled? */ |
| 191 | |
| 192 | if (!(acpi_dbg_level & info->debug_level)) { |
| 193 | return (AE_OK); |
| 194 | } |
| 195 | |
| 196 | if (!obj_handle) { |
| 197 | ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); |
| 198 | return (AE_OK); |
| 199 | } |
| 200 | |
| 201 | this_node = acpi_ns_map_handle_to_node (obj_handle); |
| 202 | type = this_node->type; |
| 203 | |
| 204 | /* Check if the owner matches */ |
| 205 | |
| 206 | if ((info->owner_id != ACPI_UINT32_MAX) && |
| 207 | (info->owner_id != this_node->owner_id)) { |
| 208 | return (AE_OK); |
| 209 | } |
| 210 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame^] | 211 | if (!(info->display_type & ACPI_DISPLAY_SHORT)) { |
| 212 | /* Indent the object according to the level */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame^] | 214 | acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame^] | 216 | /* Check the node type and name */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame^] | 218 | if (type > ACPI_TYPE_LOCAL_MAX) { |
| 219 | ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); |
| 220 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame^] | 222 | if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { |
| 223 | ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", |
| 224 | this_node->name.integer)); |
| 225 | } |
| 226 | |
| 227 | acpi_os_printf ("%4.4s", acpi_ut_get_node_name (this_node)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | /* |
| 231 | * Now we can print out the pertinent information |
| 232 | */ |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame^] | 233 | acpi_os_printf (" %-12s %p ", |
| 234 | acpi_ut_get_type_name (type), this_node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
| 236 | dbg_level = acpi_dbg_level; |
| 237 | acpi_dbg_level = 0; |
| 238 | obj_desc = acpi_ns_get_attached_object (this_node); |
| 239 | acpi_dbg_level = dbg_level; |
| 240 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame^] | 241 | switch (info->display_type & ACPI_DISPLAY_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | case ACPI_DISPLAY_SUMMARY: |
| 243 | |
| 244 | if (!obj_desc) { |
| 245 | /* No attached object, we are done */ |
| 246 | |
| 247 | acpi_os_printf ("\n"); |
| 248 | return (AE_OK); |
| 249 | } |
| 250 | |
| 251 | switch (type) { |
| 252 | case ACPI_TYPE_PROCESSOR: |
| 253 | |
| 254 | acpi_os_printf ("ID %X Len %.4X Addr %p\n", |
| 255 | obj_desc->processor.proc_id, obj_desc->processor.length, |
| 256 | (char *) obj_desc->processor.address); |
| 257 | break; |
| 258 | |
| 259 | |
| 260 | case ACPI_TYPE_DEVICE: |
| 261 | |
| 262 | acpi_os_printf ("Notify Object: %p\n", obj_desc); |
| 263 | break; |
| 264 | |
| 265 | |
| 266 | case ACPI_TYPE_METHOD: |
| 267 | |
| 268 | acpi_os_printf ("Args %X Len %.4X Aml %p\n", |
| 269 | (u32) obj_desc->method.param_count, |
| 270 | obj_desc->method.aml_length, obj_desc->method.aml_start); |
| 271 | break; |
| 272 | |
| 273 | |
| 274 | case ACPI_TYPE_INTEGER: |
| 275 | |
| 276 | acpi_os_printf ("= %8.8X%8.8X\n", |
| 277 | ACPI_FORMAT_UINT64 (obj_desc->integer.value)); |
| 278 | break; |
| 279 | |
| 280 | |
| 281 | case ACPI_TYPE_PACKAGE: |
| 282 | |
| 283 | if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { |
| 284 | acpi_os_printf ("Elements %.2X\n", |
| 285 | obj_desc->package.count); |
| 286 | } |
| 287 | else { |
| 288 | acpi_os_printf ("[Length not yet evaluated]\n"); |
| 289 | } |
| 290 | break; |
| 291 | |
| 292 | |
| 293 | case ACPI_TYPE_BUFFER: |
| 294 | |
| 295 | if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { |
| 296 | acpi_os_printf ("Len %.2X", |
| 297 | obj_desc->buffer.length); |
| 298 | |
| 299 | /* Dump some of the buffer */ |
| 300 | |
| 301 | if (obj_desc->buffer.length > 0) { |
| 302 | acpi_os_printf (" ="); |
| 303 | for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) { |
| 304 | acpi_os_printf (" %.2hX", obj_desc->buffer.pointer[i]); |
| 305 | } |
| 306 | } |
| 307 | acpi_os_printf ("\n"); |
| 308 | } |
| 309 | else { |
| 310 | acpi_os_printf ("[Length not yet evaluated]\n"); |
| 311 | } |
| 312 | break; |
| 313 | |
| 314 | |
| 315 | case ACPI_TYPE_STRING: |
| 316 | |
| 317 | acpi_os_printf ("Len %.2X ", obj_desc->string.length); |
| 318 | acpi_ut_print_string (obj_desc->string.pointer, 32); |
| 319 | acpi_os_printf ("\n"); |
| 320 | break; |
| 321 | |
| 322 | |
| 323 | case ACPI_TYPE_REGION: |
| 324 | |
| 325 | acpi_os_printf ("[%s]", |
| 326 | acpi_ut_get_region_name (obj_desc->region.space_id)); |
| 327 | if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { |
| 328 | acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n", |
| 329 | ACPI_FORMAT_UINT64 (obj_desc->region.address), |
| 330 | obj_desc->region.length); |
| 331 | } |
| 332 | else { |
| 333 | acpi_os_printf (" [Address/Length not yet evaluated]\n"); |
| 334 | } |
| 335 | break; |
| 336 | |
| 337 | |
| 338 | case ACPI_TYPE_LOCAL_REFERENCE: |
| 339 | |
| 340 | acpi_os_printf ("[%s]\n", |
| 341 | acpi_ps_get_opcode_name (obj_desc->reference.opcode)); |
| 342 | break; |
| 343 | |
| 344 | |
| 345 | case ACPI_TYPE_BUFFER_FIELD: |
| 346 | |
| 347 | if (obj_desc->buffer_field.buffer_obj && |
| 348 | obj_desc->buffer_field.buffer_obj->buffer.node) { |
| 349 | acpi_os_printf ("Buf [%4.4s]", |
| 350 | acpi_ut_get_node_name (obj_desc->buffer_field.buffer_obj->buffer.node)); |
| 351 | } |
| 352 | break; |
| 353 | |
| 354 | |
| 355 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 356 | |
| 357 | acpi_os_printf ("Rgn [%4.4s]", |
| 358 | acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node)); |
| 359 | break; |
| 360 | |
| 361 | |
| 362 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 363 | |
| 364 | acpi_os_printf ("Rgn [%4.4s] Bnk [%4.4s]", |
| 365 | acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node), |
| 366 | acpi_ut_get_node_name (obj_desc->bank_field.bank_obj->common_field.node)); |
| 367 | break; |
| 368 | |
| 369 | |
| 370 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 371 | |
| 372 | acpi_os_printf ("Idx [%4.4s] Dat [%4.4s]", |
| 373 | acpi_ut_get_node_name (obj_desc->index_field.index_obj->common_field.node), |
| 374 | acpi_ut_get_node_name (obj_desc->index_field.data_obj->common_field.node)); |
| 375 | break; |
| 376 | |
| 377 | |
| 378 | case ACPI_TYPE_LOCAL_ALIAS: |
| 379 | case ACPI_TYPE_LOCAL_METHOD_ALIAS: |
| 380 | |
| 381 | acpi_os_printf ("Target %4.4s (%p)\n", |
| 382 | acpi_ut_get_node_name (obj_desc), obj_desc); |
| 383 | break; |
| 384 | |
| 385 | default: |
| 386 | |
| 387 | acpi_os_printf ("Object %p\n", obj_desc); |
| 388 | break; |
| 389 | } |
| 390 | |
| 391 | /* Common field handling */ |
| 392 | |
| 393 | switch (type) { |
| 394 | case ACPI_TYPE_BUFFER_FIELD: |
| 395 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 396 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 397 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 398 | |
| 399 | acpi_os_printf (" Off %.3X Len %.2X Acc %.2hd\n", |
| 400 | (obj_desc->common_field.base_byte_offset * 8) |
| 401 | + obj_desc->common_field.start_field_bit_offset, |
| 402 | obj_desc->common_field.bit_length, |
| 403 | obj_desc->common_field.access_byte_width); |
| 404 | break; |
| 405 | |
| 406 | default: |
| 407 | break; |
| 408 | } |
| 409 | break; |
| 410 | |
| 411 | |
| 412 | case ACPI_DISPLAY_OBJECTS: |
| 413 | |
| 414 | acpi_os_printf ("O:%p", obj_desc); |
| 415 | if (!obj_desc) { |
| 416 | /* No attached object, we are done */ |
| 417 | |
| 418 | acpi_os_printf ("\n"); |
| 419 | return (AE_OK); |
| 420 | } |
| 421 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 422 | acpi_os_printf ("(R%d)", obj_desc->common.reference_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | |
| 424 | switch (type) { |
| 425 | case ACPI_TYPE_METHOD: |
| 426 | |
| 427 | /* Name is a Method and its AML offset/length are set */ |
| 428 | |
| 429 | acpi_os_printf (" M:%p-%X\n", obj_desc->method.aml_start, |
| 430 | obj_desc->method.aml_length); |
| 431 | break; |
| 432 | |
| 433 | case ACPI_TYPE_INTEGER: |
| 434 | |
| 435 | acpi_os_printf (" I:%8.8X8.8%X\n", |
| 436 | ACPI_FORMAT_UINT64 (obj_desc->integer.value)); |
| 437 | break; |
| 438 | |
| 439 | case ACPI_TYPE_STRING: |
| 440 | |
| 441 | acpi_os_printf (" S:%p-%X\n", obj_desc->string.pointer, |
| 442 | obj_desc->string.length); |
| 443 | break; |
| 444 | |
| 445 | case ACPI_TYPE_BUFFER: |
| 446 | |
| 447 | acpi_os_printf (" B:%p-%X\n", obj_desc->buffer.pointer, |
| 448 | obj_desc->buffer.length); |
| 449 | break; |
| 450 | |
| 451 | default: |
| 452 | |
| 453 | acpi_os_printf ("\n"); |
| 454 | break; |
| 455 | } |
| 456 | break; |
| 457 | |
| 458 | |
| 459 | default: |
| 460 | acpi_os_printf ("\n"); |
| 461 | break; |
| 462 | } |
| 463 | |
| 464 | /* If debug turned off, done */ |
| 465 | |
| 466 | if (!(acpi_dbg_level & ACPI_LV_VALUES)) { |
| 467 | return (AE_OK); |
| 468 | } |
| 469 | |
| 470 | |
| 471 | /* If there is an attached object, display it */ |
| 472 | |
| 473 | dbg_level = acpi_dbg_level; |
| 474 | acpi_dbg_level = 0; |
| 475 | obj_desc = acpi_ns_get_attached_object (this_node); |
| 476 | acpi_dbg_level = dbg_level; |
| 477 | |
| 478 | /* Dump attached objects */ |
| 479 | |
| 480 | while (obj_desc) { |
| 481 | obj_type = ACPI_TYPE_INVALID; |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 482 | acpi_os_printf ("Attached Object %p: ", obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | |
| 484 | /* Decode the type of attached object and dump the contents */ |
| 485 | |
| 486 | switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { |
| 487 | case ACPI_DESC_TYPE_NAMED: |
| 488 | |
| 489 | acpi_os_printf ("(Ptr to Node)\n"); |
| 490 | bytes_to_dump = sizeof (struct acpi_namespace_node); |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 491 | ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | break; |
| 493 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | case ACPI_DESC_TYPE_OPERAND: |
| 495 | |
| 496 | obj_type = ACPI_GET_OBJECT_TYPE (obj_desc); |
| 497 | |
| 498 | if (obj_type > ACPI_TYPE_LOCAL_MAX) { |
| 499 | acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", |
| 500 | obj_type); |
| 501 | bytes_to_dump = 32; |
| 502 | } |
| 503 | else { |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 504 | acpi_os_printf ("(Ptr to ACPI Object type %X [%s])\n", |
| 505 | obj_type, acpi_ut_get_type_name (obj_type)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | bytes_to_dump = sizeof (union acpi_operand_object); |
| 507 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 509 | ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); |
| 510 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | |
| 512 | default: |
| 513 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | break; |
| 515 | } |
| 516 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | /* If value is NOT an internal object, we are done */ |
| 518 | |
| 519 | if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { |
| 520 | goto cleanup; |
| 521 | } |
| 522 | |
| 523 | /* |
| 524 | * Valid object, get the pointer to next level, if any |
| 525 | */ |
| 526 | switch (obj_type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | case ACPI_TYPE_BUFFER: |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 528 | case ACPI_TYPE_STRING: |
| 529 | /* |
| 530 | * NOTE: takes advantage of common fields between string/buffer |
| 531 | */ |
| 532 | bytes_to_dump = obj_desc->string.length; |
| 533 | obj_desc = (void *) obj_desc->string.pointer; |
| 534 | acpi_os_printf ( "(Buffer/String pointer %p length %X)\n", |
| 535 | obj_desc, bytes_to_dump); |
| 536 | ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump); |
| 537 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | |
| 539 | case ACPI_TYPE_BUFFER_FIELD: |
| 540 | obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj; |
| 541 | break; |
| 542 | |
| 543 | case ACPI_TYPE_PACKAGE: |
| 544 | obj_desc = (void *) obj_desc->package.elements; |
| 545 | break; |
| 546 | |
| 547 | case ACPI_TYPE_METHOD: |
| 548 | obj_desc = (void *) obj_desc->method.aml_start; |
| 549 | break; |
| 550 | |
| 551 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 552 | obj_desc = (void *) obj_desc->field.region_obj; |
| 553 | break; |
| 554 | |
| 555 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 556 | obj_desc = (void *) obj_desc->bank_field.region_obj; |
| 557 | break; |
| 558 | |
| 559 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 560 | obj_desc = (void *) obj_desc->index_field.index_obj; |
| 561 | break; |
| 562 | |
| 563 | default: |
| 564 | goto cleanup; |
| 565 | } |
| 566 | |
| 567 | obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ |
| 568 | } |
| 569 | |
| 570 | cleanup: |
| 571 | acpi_os_printf ("\n"); |
| 572 | return (AE_OK); |
| 573 | } |
| 574 | |
| 575 | |
| 576 | #ifdef ACPI_FUTURE_USAGE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | /******************************************************************************* |
| 578 | * |
| 579 | * FUNCTION: acpi_ns_dump_objects |
| 580 | * |
| 581 | * PARAMETERS: Type - Object type to be dumped |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 582 | * display_type - 0 or ACPI_DISPLAY_SUMMARY |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX |
| 584 | * for an effectively unlimited depth. |
| 585 | * owner_id - Dump only objects owned by this ID. Use |
| 586 | * ACPI_UINT32_MAX to match all owners. |
| 587 | * start_handle - Where in namespace to start/end search |
| 588 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 589 | * RETURN: None |
| 590 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | * DESCRIPTION: Dump typed objects within the loaded namespace. |
| 592 | * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object. |
| 593 | * |
| 594 | ******************************************************************************/ |
| 595 | |
| 596 | void |
| 597 | acpi_ns_dump_objects ( |
| 598 | acpi_object_type type, |
| 599 | u8 display_type, |
| 600 | u32 max_depth, |
| 601 | u32 owner_id, |
| 602 | acpi_handle start_handle) |
| 603 | { |
| 604 | struct acpi_walk_info info; |
| 605 | |
| 606 | |
| 607 | ACPI_FUNCTION_ENTRY (); |
| 608 | |
| 609 | |
| 610 | info.debug_level = ACPI_LV_TABLES; |
| 611 | info.owner_id = owner_id; |
| 612 | info.display_type = display_type; |
| 613 | |
| 614 | (void) acpi_ns_walk_namespace (type, start_handle, max_depth, |
| 615 | ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object, |
| 616 | (void *) &info, NULL); |
| 617 | } |
Len Brown | a27ac38 | 2019-04-05 00:07:45 -0500 | [diff] [blame] | 618 | #endif /* ACPI_FUTURE_USAGE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
| 620 | |
| 621 | /******************************************************************************* |
| 622 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 623 | * FUNCTION: acpi_ns_dump_entry |
| 624 | * |
| 625 | * PARAMETERS: Handle - Node to be dumped |
| 626 | * debug_level - Output level |
| 627 | * |
| 628 | * RETURN: None |
| 629 | * |
| 630 | * DESCRIPTION: Dump a single Node |
| 631 | * |
| 632 | ******************************************************************************/ |
| 633 | |
| 634 | void |
| 635 | acpi_ns_dump_entry ( |
| 636 | acpi_handle handle, |
| 637 | u32 debug_level) |
| 638 | { |
| 639 | struct acpi_walk_info info; |
| 640 | |
| 641 | |
| 642 | ACPI_FUNCTION_ENTRY (); |
| 643 | |
| 644 | |
| 645 | info.debug_level = debug_level; |
| 646 | info.owner_id = ACPI_UINT32_MAX; |
| 647 | info.display_type = ACPI_DISPLAY_SUMMARY; |
| 648 | |
| 649 | (void) acpi_ns_dump_one_object (handle, 1, &info, NULL); |
| 650 | } |
| 651 | |
| 652 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame^] | 653 | #ifdef ACPI_ASL_COMPILER |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 654 | /******************************************************************************* |
| 655 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | * FUNCTION: acpi_ns_dump_tables |
| 657 | * |
| 658 | * PARAMETERS: search_base - Root of subtree to be dumped, or |
| 659 | * NS_ALL to dump the entire namespace |
| 660 | * max_depth - Maximum depth of dump. Use INT_MAX |
| 661 | * for an effectively unlimited depth. |
| 662 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 663 | * RETURN: None |
| 664 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | * DESCRIPTION: Dump the name space, or a portion of it. |
| 666 | * |
| 667 | ******************************************************************************/ |
| 668 | |
| 669 | void |
| 670 | acpi_ns_dump_tables ( |
| 671 | acpi_handle search_base, |
| 672 | u32 max_depth) |
| 673 | { |
| 674 | acpi_handle search_handle = search_base; |
| 675 | |
| 676 | |
| 677 | ACPI_FUNCTION_TRACE ("ns_dump_tables"); |
| 678 | |
| 679 | |
| 680 | if (!acpi_gbl_root_node) { |
| 681 | /* |
| 682 | * If the name space has not been initialized, |
| 683 | * there is nothing to dump. |
| 684 | */ |
| 685 | ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); |
| 686 | return_VOID; |
| 687 | } |
| 688 | |
| 689 | if (ACPI_NS_ALL == search_base) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 690 | /* Entire namespace */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | |
| 692 | search_handle = acpi_gbl_root_node; |
| 693 | ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); |
| 694 | } |
| 695 | |
| 696 | acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth, |
| 697 | ACPI_UINT32_MAX, search_handle); |
| 698 | return_VOID; |
| 699 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 700 | #endif /* _ACPI_ASL_COMPILER */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 701 | #endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */ |