Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: exdump - Interpreter debug output routines |
| 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/acinterp.h> |
| 47 | #include <acpi/amlcode.h> |
| 48 | #include <acpi/acnamesp.h> |
| 49 | #include <acpi/acparser.h> |
| 50 | |
| 51 | #define _COMPONENT ACPI_EXECUTER |
| 52 | ACPI_MODULE_NAME ("exdump") |
| 53 | |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame^] | 54 | /* |
| 55 | * The following routines are used for debug output only |
| 56 | */ |
| 57 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) |
| 58 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 59 | /* Local prototypes */ |
| 60 | |
| 61 | #ifdef ACPI_FUTURE_USAGE |
| 62 | static void |
| 63 | acpi_ex_out_string ( |
| 64 | char *title, |
| 65 | char *value); |
| 66 | |
| 67 | static void |
| 68 | acpi_ex_out_pointer ( |
| 69 | char *title, |
| 70 | void *value); |
| 71 | |
| 72 | static void |
| 73 | acpi_ex_out_integer ( |
| 74 | char *title, |
| 75 | u32 value); |
| 76 | |
| 77 | static void |
| 78 | acpi_ex_out_address ( |
| 79 | char *title, |
| 80 | acpi_physical_address value); |
| 81 | #endif /* ACPI_FUTURE_USAGE */ |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 84 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | * |
| 86 | * FUNCTION: acpi_ex_dump_operand |
| 87 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 88 | * PARAMETERS: *obj_desc - Pointer to entry to be dumped |
| 89 | * Depth - Current nesting depth |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | * |
| 91 | * RETURN: None |
| 92 | * |
| 93 | * DESCRIPTION: Dump an operand object |
| 94 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 95 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | void |
| 98 | acpi_ex_dump_operand ( |
| 99 | union acpi_operand_object *obj_desc, |
| 100 | u32 depth) |
| 101 | { |
| 102 | u32 length; |
| 103 | u32 index; |
| 104 | |
| 105 | |
| 106 | ACPI_FUNCTION_NAME ("ex_dump_operand") |
| 107 | |
| 108 | |
| 109 | if (!((ACPI_LV_EXEC & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { |
| 110 | return; |
| 111 | } |
| 112 | |
| 113 | if (!obj_desc) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 114 | /* This could be a null element of a package */ |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame^] | 121 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC); |
| 123 | return; |
| 124 | } |
| 125 | |
| 126 | if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { |
| 127 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, |
| 128 | "%p is not a node or operand object: [%s]\n", |
| 129 | obj_desc, acpi_ut_get_descriptor_name (obj_desc))); |
| 130 | ACPI_DUMP_BUFFER (obj_desc, sizeof (union acpi_operand_object)); |
| 131 | return; |
| 132 | } |
| 133 | |
| 134 | /* obj_desc is a valid object */ |
| 135 | |
| 136 | if (depth > 0) { |
| 137 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ", |
| 138 | depth, " ", depth, obj_desc)); |
| 139 | } |
| 140 | else { |
| 141 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc)); |
| 142 | } |
| 143 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 144 | /* Decode object type */ |
| 145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { |
| 147 | case ACPI_TYPE_LOCAL_REFERENCE: |
| 148 | |
| 149 | switch (obj_desc->reference.opcode) { |
| 150 | case AML_DEBUG_OP: |
| 151 | |
| 152 | acpi_os_printf ("Reference: Debug\n"); |
| 153 | break; |
| 154 | |
| 155 | |
| 156 | case AML_NAME_OP: |
| 157 | |
| 158 | ACPI_DUMP_PATHNAME (obj_desc->reference.object, |
| 159 | "Reference: Name: ", ACPI_LV_INFO, _COMPONENT); |
| 160 | ACPI_DUMP_ENTRY (obj_desc->reference.object, ACPI_LV_INFO); |
| 161 | break; |
| 162 | |
| 163 | |
| 164 | case AML_INDEX_OP: |
| 165 | |
| 166 | acpi_os_printf ("Reference: Index %p\n", |
| 167 | obj_desc->reference.object); |
| 168 | break; |
| 169 | |
| 170 | |
| 171 | case AML_REF_OF_OP: |
| 172 | |
| 173 | acpi_os_printf ("Reference: (ref_of) %p\n", |
| 174 | obj_desc->reference.object); |
| 175 | break; |
| 176 | |
| 177 | |
| 178 | case AML_ARG_OP: |
| 179 | |
| 180 | acpi_os_printf ("Reference: Arg%d", |
| 181 | obj_desc->reference.offset); |
| 182 | |
| 183 | if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { |
| 184 | /* Value is an Integer */ |
| 185 | |
| 186 | acpi_os_printf (" value is [%8.8X%8.8x]", |
| 187 | ACPI_FORMAT_UINT64 (obj_desc->integer.value)); |
| 188 | } |
| 189 | |
| 190 | acpi_os_printf ("\n"); |
| 191 | break; |
| 192 | |
| 193 | |
| 194 | case AML_LOCAL_OP: |
| 195 | |
| 196 | acpi_os_printf ("Reference: Local%d", |
| 197 | obj_desc->reference.offset); |
| 198 | |
| 199 | if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) { |
| 200 | |
| 201 | /* Value is an Integer */ |
| 202 | |
| 203 | acpi_os_printf (" value is [%8.8X%8.8x]", |
| 204 | ACPI_FORMAT_UINT64 (obj_desc->integer.value)); |
| 205 | } |
| 206 | |
| 207 | acpi_os_printf ("\n"); |
| 208 | break; |
| 209 | |
| 210 | |
| 211 | case AML_INT_NAMEPATH_OP: |
| 212 | |
| 213 | acpi_os_printf ("Reference.Node->Name %X\n", |
| 214 | obj_desc->reference.node->name.integer); |
| 215 | break; |
| 216 | |
| 217 | |
| 218 | default: |
| 219 | |
| 220 | /* Unknown opcode */ |
| 221 | |
| 222 | acpi_os_printf ("Unknown Reference opcode=%X\n", |
| 223 | obj_desc->reference.opcode); |
| 224 | break; |
| 225 | |
| 226 | } |
| 227 | break; |
| 228 | |
| 229 | |
| 230 | case ACPI_TYPE_BUFFER: |
| 231 | |
| 232 | acpi_os_printf ("Buffer len %X @ %p \n", |
| 233 | obj_desc->buffer.length, obj_desc->buffer.pointer); |
| 234 | |
| 235 | length = obj_desc->buffer.length; |
| 236 | if (length > 64) { |
| 237 | length = 64; |
| 238 | } |
| 239 | |
| 240 | /* Debug only -- dump the buffer contents */ |
| 241 | |
| 242 | if (obj_desc->buffer.pointer) { |
| 243 | acpi_os_printf ("Buffer Contents: "); |
| 244 | |
| 245 | for (index = 0; index < length; index++) { |
| 246 | acpi_os_printf (" %02x", obj_desc->buffer.pointer[index]); |
| 247 | } |
| 248 | acpi_os_printf ("\n"); |
| 249 | } |
| 250 | break; |
| 251 | |
| 252 | |
| 253 | case ACPI_TYPE_INTEGER: |
| 254 | |
| 255 | acpi_os_printf ("Integer %8.8X%8.8X\n", |
| 256 | ACPI_FORMAT_UINT64 (obj_desc->integer.value)); |
| 257 | break; |
| 258 | |
| 259 | |
| 260 | case ACPI_TYPE_PACKAGE: |
| 261 | |
| 262 | acpi_os_printf ("Package [Len %X] element_array %p\n", |
| 263 | obj_desc->package.count, obj_desc->package.elements); |
| 264 | |
| 265 | /* |
| 266 | * If elements exist, package element pointer is valid, |
| 267 | * and debug_level exceeds 1, dump package's elements. |
| 268 | */ |
| 269 | if (obj_desc->package.count && |
| 270 | obj_desc->package.elements && |
| 271 | acpi_dbg_level > 1) { |
| 272 | for (index = 0; index < obj_desc->package.count; index++) { |
| 273 | acpi_ex_dump_operand (obj_desc->package.elements[index], depth+1); |
| 274 | } |
| 275 | } |
| 276 | break; |
| 277 | |
| 278 | |
| 279 | case ACPI_TYPE_REGION: |
| 280 | |
| 281 | acpi_os_printf ("Region %s (%X)", |
| 282 | acpi_ut_get_region_name (obj_desc->region.space_id), |
| 283 | obj_desc->region.space_id); |
| 284 | |
| 285 | /* |
| 286 | * If the address and length have not been evaluated, |
| 287 | * don't print them. |
| 288 | */ |
| 289 | if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) { |
| 290 | acpi_os_printf ("\n"); |
| 291 | } |
| 292 | else { |
| 293 | acpi_os_printf (" base %8.8X%8.8X Length %X\n", |
| 294 | ACPI_FORMAT_UINT64 (obj_desc->region.address), |
| 295 | obj_desc->region.length); |
| 296 | } |
| 297 | break; |
| 298 | |
| 299 | |
| 300 | case ACPI_TYPE_STRING: |
| 301 | |
| 302 | acpi_os_printf ("String length %X @ %p ", |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 303 | obj_desc->string.length, |
| 304 | obj_desc->string.pointer); |
| 305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX); |
| 307 | acpi_os_printf ("\n"); |
| 308 | break; |
| 309 | |
| 310 | |
| 311 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 312 | |
| 313 | acpi_os_printf ("bank_field\n"); |
| 314 | break; |
| 315 | |
| 316 | |
| 317 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 318 | |
| 319 | acpi_os_printf ( |
| 320 | "region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 321 | obj_desc->field.bit_length, |
| 322 | obj_desc->field.access_byte_width, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK, |
| 324 | obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 325 | obj_desc->field.base_byte_offset, |
| 326 | obj_desc->field.start_field_bit_offset); |
| 327 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1); |
| 329 | break; |
| 330 | |
| 331 | |
| 332 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 333 | |
| 334 | acpi_os_printf ("index_field\n"); |
| 335 | break; |
| 336 | |
| 337 | |
| 338 | case ACPI_TYPE_BUFFER_FIELD: |
| 339 | |
| 340 | acpi_os_printf ( |
| 341 | "buffer_field: %X bits at byte %X bit %X of \n", |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 342 | obj_desc->buffer_field.bit_length, |
| 343 | obj_desc->buffer_field.base_byte_offset, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | obj_desc->buffer_field.start_field_bit_offset); |
| 345 | |
| 346 | if (!obj_desc->buffer_field.buffer_obj) { |
| 347 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n")); |
| 348 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 349 | else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != |
| 350 | ACPI_TYPE_BUFFER) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | acpi_os_printf ("*not a Buffer* \n"); |
| 352 | } |
| 353 | else { |
| 354 | acpi_ex_dump_operand (obj_desc->buffer_field.buffer_obj, depth+1); |
| 355 | } |
| 356 | break; |
| 357 | |
| 358 | |
| 359 | case ACPI_TYPE_EVENT: |
| 360 | |
| 361 | acpi_os_printf ("Event\n"); |
| 362 | break; |
| 363 | |
| 364 | |
| 365 | case ACPI_TYPE_METHOD: |
| 366 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 367 | acpi_os_printf ("Method(%X) @ %p:%X\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | obj_desc->method.param_count, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 369 | obj_desc->method.aml_start, |
| 370 | obj_desc->method.aml_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | break; |
| 372 | |
| 373 | |
| 374 | case ACPI_TYPE_MUTEX: |
| 375 | |
| 376 | acpi_os_printf ("Mutex\n"); |
| 377 | break; |
| 378 | |
| 379 | |
| 380 | case ACPI_TYPE_DEVICE: |
| 381 | |
| 382 | acpi_os_printf ("Device\n"); |
| 383 | break; |
| 384 | |
| 385 | |
| 386 | case ACPI_TYPE_POWER: |
| 387 | |
| 388 | acpi_os_printf ("Power\n"); |
| 389 | break; |
| 390 | |
| 391 | |
| 392 | case ACPI_TYPE_PROCESSOR: |
| 393 | |
| 394 | acpi_os_printf ("Processor\n"); |
| 395 | break; |
| 396 | |
| 397 | |
| 398 | case ACPI_TYPE_THERMAL: |
| 399 | |
| 400 | acpi_os_printf ("Thermal\n"); |
| 401 | break; |
| 402 | |
| 403 | |
| 404 | default: |
| 405 | /* Unknown Type */ |
| 406 | |
| 407 | acpi_os_printf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (obj_desc)); |
| 408 | break; |
| 409 | } |
| 410 | |
| 411 | return; |
| 412 | } |
| 413 | |
| 414 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 415 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | * |
| 417 | * FUNCTION: acpi_ex_dump_operands |
| 418 | * |
| 419 | * PARAMETERS: Operands - Operand list |
| 420 | * interpreter_mode - Load or Exec |
| 421 | * Ident - Identification |
| 422 | * num_levels - # of stack entries to dump above line |
| 423 | * Note - Output notation |
| 424 | * module_name - Caller's module name |
| 425 | * line_number - Caller's invocation line number |
| 426 | * |
| 427 | * DESCRIPTION: Dump the object stack |
| 428 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 429 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | |
| 431 | void |
| 432 | acpi_ex_dump_operands ( |
| 433 | union acpi_operand_object **operands, |
| 434 | acpi_interpreter_mode interpreter_mode, |
| 435 | char *ident, |
| 436 | u32 num_levels, |
| 437 | char *note, |
| 438 | char *module_name, |
| 439 | u32 line_number) |
| 440 | { |
| 441 | acpi_native_uint i; |
| 442 | |
| 443 | |
| 444 | ACPI_FUNCTION_NAME ("ex_dump_operands"); |
| 445 | |
| 446 | |
| 447 | if (!ident) { |
| 448 | ident = "?"; |
| 449 | } |
| 450 | |
| 451 | if (!note) { |
| 452 | note = "?"; |
| 453 | } |
| 454 | |
| 455 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, |
| 456 | "************* Operand Stack Contents (Opcode [%s], %d Operands)\n", |
| 457 | ident, num_levels)); |
| 458 | |
| 459 | if (num_levels == 0) { |
| 460 | num_levels = 1; |
| 461 | } |
| 462 | |
| 463 | /* Dump the operand stack starting at the top */ |
| 464 | |
| 465 | for (i = 0; num_levels > 0; i--, num_levels--) { |
| 466 | acpi_ex_dump_operand (operands[i], 0); |
| 467 | } |
| 468 | |
| 469 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame^] | 470 | "************* Operand Stack dump from %s(%d), %s\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | module_name, line_number, note)); |
| 472 | return; |
| 473 | } |
| 474 | |
| 475 | |
| 476 | #ifdef ACPI_FUTURE_USAGE |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 477 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 479 | * FUNCTION: acpi_ex_out* functions |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | * |
| 481 | * PARAMETERS: Title - Descriptive text |
| 482 | * Value - Value to be displayed |
| 483 | * |
| 484 | * DESCRIPTION: Object dump output formatting functions. These functions |
| 485 | * reduce the number of format strings required and keeps them |
| 486 | * all in one place for easy modification. |
| 487 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 488 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 490 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | acpi_ex_out_string ( |
| 492 | char *title, |
| 493 | char *value) |
| 494 | { |
| 495 | acpi_os_printf ("%20s : %s\n", title, value); |
| 496 | } |
| 497 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 498 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | acpi_ex_out_pointer ( |
| 500 | char *title, |
| 501 | void *value) |
| 502 | { |
| 503 | acpi_os_printf ("%20s : %p\n", title, value); |
| 504 | } |
| 505 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 506 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | acpi_ex_out_integer ( |
| 508 | char *title, |
| 509 | u32 value) |
| 510 | { |
| 511 | acpi_os_printf ("%20s : %X\n", title, value); |
| 512 | } |
| 513 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 514 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | acpi_ex_out_address ( |
| 516 | char *title, |
| 517 | acpi_physical_address value) |
| 518 | { |
| 519 | |
| 520 | #if ACPI_MACHINE_WIDTH == 16 |
| 521 | acpi_os_printf ("%20s : %p\n", title, value); |
| 522 | #else |
| 523 | acpi_os_printf ("%20s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64 (value)); |
| 524 | #endif |
| 525 | } |
| 526 | |
| 527 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 528 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | * |
| 530 | * FUNCTION: acpi_ex_dump_node |
| 531 | * |
| 532 | * PARAMETERS: *Node - Descriptor to dump |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 533 | * Flags - Force display if TRUE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | * |
| 535 | * DESCRIPTION: Dumps the members of the given.Node |
| 536 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 537 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | |
| 539 | void |
| 540 | acpi_ex_dump_node ( |
| 541 | struct acpi_namespace_node *node, |
| 542 | u32 flags) |
| 543 | { |
| 544 | |
| 545 | ACPI_FUNCTION_ENTRY (); |
| 546 | |
| 547 | |
| 548 | if (!flags) { |
| 549 | if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { |
| 550 | return; |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | acpi_os_printf ("%20s : %4.4s\n", "Name", acpi_ut_get_node_name (node)); |
| 555 | acpi_ex_out_string ("Type", acpi_ut_get_type_name (node->type)); |
| 556 | acpi_ex_out_integer ("Flags", node->flags); |
| 557 | acpi_ex_out_integer ("Owner Id", node->owner_id); |
| 558 | acpi_ex_out_integer ("Reference Count", node->reference_count); |
| 559 | acpi_ex_out_pointer ("Attached Object", acpi_ns_get_attached_object (node)); |
| 560 | acpi_ex_out_pointer ("child_list", node->child); |
| 561 | acpi_ex_out_pointer ("next_peer", node->peer); |
| 562 | acpi_ex_out_pointer ("Parent", acpi_ns_get_parent_node (node)); |
| 563 | } |
| 564 | |
| 565 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 566 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | * |
| 568 | * FUNCTION: acpi_ex_dump_object_descriptor |
| 569 | * |
| 570 | * PARAMETERS: *Object - Descriptor to dump |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 571 | * Flags - Force display if TRUE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | * |
| 573 | * DESCRIPTION: Dumps the members of the object descriptor given. |
| 574 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 575 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | |
| 577 | void |
| 578 | acpi_ex_dump_object_descriptor ( |
| 579 | union acpi_operand_object *obj_desc, |
| 580 | u32 flags) |
| 581 | { |
| 582 | u32 i; |
| 583 | |
| 584 | |
| 585 | ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); |
| 586 | |
| 587 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 588 | if (!obj_desc) { |
| 589 | return_VOID; |
| 590 | } |
| 591 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | if (!flags) { |
| 593 | if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) { |
| 594 | return_VOID; |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) { |
| 599 | acpi_ex_dump_node ((struct acpi_namespace_node *) obj_desc, flags); |
| 600 | acpi_os_printf ("\nAttached Object (%p):\n", |
| 601 | ((struct acpi_namespace_node *) obj_desc)->object); |
| 602 | acpi_ex_dump_object_descriptor ( |
| 603 | ((struct acpi_namespace_node *) obj_desc)->object, flags); |
| 604 | return_VOID; |
| 605 | } |
| 606 | |
| 607 | if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) { |
| 608 | acpi_os_printf ( |
| 609 | "ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n", |
| 610 | obj_desc, acpi_ut_get_descriptor_name (obj_desc)); |
| 611 | return_VOID; |
| 612 | } |
| 613 | |
| 614 | /* Common Fields */ |
| 615 | |
| 616 | acpi_ex_out_string ("Type", acpi_ut_get_object_type_name (obj_desc)); |
| 617 | acpi_ex_out_integer ("Reference Count", obj_desc->common.reference_count); |
| 618 | acpi_ex_out_integer ("Flags", obj_desc->common.flags); |
| 619 | |
| 620 | /* Object-specific Fields */ |
| 621 | |
| 622 | switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { |
| 623 | case ACPI_TYPE_INTEGER: |
| 624 | |
| 625 | acpi_os_printf ("%20s : %8.8X%8.8X\n", "Value", |
| 626 | ACPI_FORMAT_UINT64 (obj_desc->integer.value)); |
| 627 | break; |
| 628 | |
| 629 | |
| 630 | case ACPI_TYPE_STRING: |
| 631 | |
| 632 | acpi_ex_out_integer ("Length", obj_desc->string.length); |
| 633 | |
| 634 | acpi_os_printf ("%20s : %p ", "Pointer", obj_desc->string.pointer); |
| 635 | acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX); |
| 636 | acpi_os_printf ("\n"); |
| 637 | break; |
| 638 | |
| 639 | |
| 640 | case ACPI_TYPE_BUFFER: |
| 641 | |
| 642 | acpi_ex_out_integer ("Length", obj_desc->buffer.length); |
| 643 | acpi_ex_out_pointer ("Pointer", obj_desc->buffer.pointer); |
| 644 | ACPI_DUMP_BUFFER (obj_desc->buffer.pointer, obj_desc->buffer.length); |
| 645 | break; |
| 646 | |
| 647 | |
| 648 | case ACPI_TYPE_PACKAGE: |
| 649 | |
| 650 | acpi_ex_out_integer ("Flags", obj_desc->package.flags); |
| 651 | acpi_ex_out_integer ("Count", obj_desc->package.count); |
| 652 | acpi_ex_out_pointer ("Elements", obj_desc->package.elements); |
| 653 | |
| 654 | /* Dump the package contents */ |
| 655 | |
| 656 | if (obj_desc->package.count > 0) { |
| 657 | acpi_os_printf ("\nPackage Contents:\n"); |
| 658 | for (i = 0; i < obj_desc->package.count; i++) { |
| 659 | acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]); |
| 660 | if (obj_desc->package.elements[i]) { |
| 661 | acpi_os_printf (" %s", |
| 662 | acpi_ut_get_object_type_name (obj_desc->package.elements[i])); |
| 663 | } |
| 664 | acpi_os_printf ("\n"); |
| 665 | } |
| 666 | } |
| 667 | break; |
| 668 | |
| 669 | |
| 670 | case ACPI_TYPE_DEVICE: |
| 671 | |
| 672 | acpi_ex_out_pointer ("Handler", obj_desc->device.handler); |
| 673 | acpi_ex_out_pointer ("system_notify", obj_desc->device.system_notify); |
| 674 | acpi_ex_out_pointer ("device_notify", obj_desc->device.device_notify); |
| 675 | break; |
| 676 | |
| 677 | |
| 678 | case ACPI_TYPE_EVENT: |
| 679 | |
| 680 | acpi_ex_out_pointer ("Semaphore", obj_desc->event.semaphore); |
| 681 | break; |
| 682 | |
| 683 | |
| 684 | case ACPI_TYPE_METHOD: |
| 685 | |
| 686 | acpi_ex_out_integer ("param_count", obj_desc->method.param_count); |
| 687 | acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency); |
| 688 | acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore); |
| 689 | acpi_ex_out_integer ("owning_id", obj_desc->method.owning_id); |
| 690 | acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length); |
| 691 | acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start); |
| 692 | break; |
| 693 | |
| 694 | |
| 695 | case ACPI_TYPE_MUTEX: |
| 696 | |
| 697 | acpi_ex_out_integer ("sync_level", obj_desc->mutex.sync_level); |
| 698 | acpi_ex_out_pointer ("owner_thread", obj_desc->mutex.owner_thread); |
| 699 | acpi_ex_out_integer ("acquire_depth", obj_desc->mutex.acquisition_depth); |
| 700 | acpi_ex_out_pointer ("Semaphore", obj_desc->mutex.semaphore); |
| 701 | break; |
| 702 | |
| 703 | |
| 704 | case ACPI_TYPE_REGION: |
| 705 | |
| 706 | acpi_ex_out_integer ("space_id", obj_desc->region.space_id); |
| 707 | acpi_ex_out_integer ("Flags", obj_desc->region.flags); |
| 708 | acpi_ex_out_address ("Address", obj_desc->region.address); |
| 709 | acpi_ex_out_integer ("Length", obj_desc->region.length); |
| 710 | acpi_ex_out_pointer ("Handler", obj_desc->region.handler); |
| 711 | acpi_ex_out_pointer ("Next", obj_desc->region.next); |
| 712 | break; |
| 713 | |
| 714 | |
| 715 | case ACPI_TYPE_POWER: |
| 716 | |
| 717 | acpi_ex_out_integer ("system_level", obj_desc->power_resource.system_level); |
| 718 | acpi_ex_out_integer ("resource_order", obj_desc->power_resource.resource_order); |
| 719 | acpi_ex_out_pointer ("system_notify", obj_desc->power_resource.system_notify); |
| 720 | acpi_ex_out_pointer ("device_notify", obj_desc->power_resource.device_notify); |
| 721 | break; |
| 722 | |
| 723 | |
| 724 | case ACPI_TYPE_PROCESSOR: |
| 725 | |
| 726 | acpi_ex_out_integer ("Processor ID", obj_desc->processor.proc_id); |
| 727 | acpi_ex_out_integer ("Length", obj_desc->processor.length); |
| 728 | acpi_ex_out_address ("Address", (acpi_physical_address) obj_desc->processor.address); |
| 729 | acpi_ex_out_pointer ("system_notify", obj_desc->processor.system_notify); |
| 730 | acpi_ex_out_pointer ("device_notify", obj_desc->processor.device_notify); |
| 731 | acpi_ex_out_pointer ("Handler", obj_desc->processor.handler); |
| 732 | break; |
| 733 | |
| 734 | |
| 735 | case ACPI_TYPE_THERMAL: |
| 736 | |
| 737 | acpi_ex_out_pointer ("system_notify", obj_desc->thermal_zone.system_notify); |
| 738 | acpi_ex_out_pointer ("device_notify", obj_desc->thermal_zone.device_notify); |
| 739 | acpi_ex_out_pointer ("Handler", obj_desc->thermal_zone.handler); |
| 740 | break; |
| 741 | |
| 742 | |
| 743 | case ACPI_TYPE_BUFFER_FIELD: |
| 744 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 745 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 746 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 747 | |
| 748 | acpi_ex_out_integer ("field_flags", obj_desc->common_field.field_flags); |
| 749 | acpi_ex_out_integer ("access_byte_width",obj_desc->common_field.access_byte_width); |
| 750 | acpi_ex_out_integer ("bit_length", obj_desc->common_field.bit_length); |
| 751 | acpi_ex_out_integer ("fld_bit_offset", obj_desc->common_field.start_field_bit_offset); |
| 752 | acpi_ex_out_integer ("base_byte_offset", obj_desc->common_field.base_byte_offset); |
| 753 | acpi_ex_out_pointer ("parent_node", obj_desc->common_field.node); |
| 754 | |
| 755 | switch (ACPI_GET_OBJECT_TYPE (obj_desc)) { |
| 756 | case ACPI_TYPE_BUFFER_FIELD: |
| 757 | acpi_ex_out_pointer ("buffer_obj", obj_desc->buffer_field.buffer_obj); |
| 758 | break; |
| 759 | |
| 760 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 761 | acpi_ex_out_pointer ("region_obj", obj_desc->field.region_obj); |
| 762 | break; |
| 763 | |
| 764 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 765 | acpi_ex_out_integer ("Value", obj_desc->bank_field.value); |
| 766 | acpi_ex_out_pointer ("region_obj", obj_desc->bank_field.region_obj); |
| 767 | acpi_ex_out_pointer ("bank_obj", obj_desc->bank_field.bank_obj); |
| 768 | break; |
| 769 | |
| 770 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 771 | acpi_ex_out_integer ("Value", obj_desc->index_field.value); |
| 772 | acpi_ex_out_pointer ("Index", obj_desc->index_field.index_obj); |
| 773 | acpi_ex_out_pointer ("Data", obj_desc->index_field.data_obj); |
| 774 | break; |
| 775 | |
| 776 | default: |
| 777 | /* All object types covered above */ |
| 778 | break; |
| 779 | } |
| 780 | break; |
| 781 | |
| 782 | |
| 783 | case ACPI_TYPE_LOCAL_REFERENCE: |
| 784 | |
| 785 | acpi_ex_out_integer ("target_type", obj_desc->reference.target_type); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 786 | acpi_ex_out_string ("Opcode", (acpi_ps_get_opcode_info ( |
| 787 | obj_desc->reference.opcode))->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | acpi_ex_out_integer ("Offset", obj_desc->reference.offset); |
| 789 | acpi_ex_out_pointer ("obj_desc", obj_desc->reference.object); |
| 790 | acpi_ex_out_pointer ("Node", obj_desc->reference.node); |
| 791 | acpi_ex_out_pointer ("Where", obj_desc->reference.where); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 792 | |
| 793 | if (obj_desc->reference.object) { |
| 794 | acpi_os_printf ("\nReferenced Object:\n"); |
| 795 | acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags); |
| 796 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | break; |
| 798 | |
| 799 | |
| 800 | case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: |
| 801 | |
| 802 | acpi_ex_out_integer ("space_id", obj_desc->address_space.space_id); |
| 803 | acpi_ex_out_pointer ("Next", obj_desc->address_space.next); |
| 804 | acpi_ex_out_pointer ("region_list", obj_desc->address_space.region_list); |
| 805 | acpi_ex_out_pointer ("Node", obj_desc->address_space.node); |
| 806 | acpi_ex_out_pointer ("Context", obj_desc->address_space.context); |
| 807 | break; |
| 808 | |
| 809 | |
| 810 | case ACPI_TYPE_LOCAL_NOTIFY: |
| 811 | |
| 812 | acpi_ex_out_pointer ("Node", obj_desc->notify.node); |
| 813 | acpi_ex_out_pointer ("Context", obj_desc->notify.context); |
| 814 | break; |
| 815 | |
| 816 | |
| 817 | case ACPI_TYPE_LOCAL_ALIAS: |
| 818 | case ACPI_TYPE_LOCAL_METHOD_ALIAS: |
| 819 | case ACPI_TYPE_LOCAL_EXTRA: |
| 820 | case ACPI_TYPE_LOCAL_DATA: |
| 821 | default: |
| 822 | |
| 823 | acpi_os_printf ( |
| 824 | "ex_dump_object_descriptor: Display not implemented for object type %s\n", |
| 825 | acpi_ut_get_object_type_name (obj_desc)); |
| 826 | break; |
| 827 | } |
| 828 | |
| 829 | return_VOID; |
| 830 | } |
| 831 | |
| 832 | #endif /* ACPI_FUTURE_USAGE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 833 | #endif |
| 834 | |