1 /******************************************************************************
3 * Module Name: exdump - Interpreter debug output routines
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2004, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
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>
51 #define _COMPONENT ACPI_EXECUTER
52 ACPI_MODULE_NAME ("exdump")
56 * The following routines are used for debug output only
58 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
60 /*****************************************************************************
62 * FUNCTION: acpi_ex_dump_operand
64 * PARAMETERS: *obj_desc - Pointer to entry to be dumped
68 * DESCRIPTION: Dump an operand object
70 ****************************************************************************/
73 acpi_ex_dump_operand (
74 union acpi_operand_object *obj_desc,
81 ACPI_FUNCTION_NAME ("ex_dump_operand")
84 if (!((ACPI_LV_EXEC & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
90 * This could be a null element of a package
92 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
96 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
97 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is a NS Node: ", obj_desc));
98 ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC);
102 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
103 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
104 "%p is not a node or operand object: [%s]\n",
105 obj_desc, acpi_ut_get_descriptor_name (obj_desc)));
106 ACPI_DUMP_BUFFER (obj_desc, sizeof (union acpi_operand_object));
110 /* obj_desc is a valid object */
113 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "%*s[%u] ", depth, " ", depth));
115 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "%p ", obj_desc));
118 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
119 case ACPI_TYPE_LOCAL_REFERENCE:
121 switch (obj_desc->reference.opcode) {
124 acpi_os_printf ("Reference: Debug\n");
130 ACPI_DUMP_PATHNAME (obj_desc->reference.object,
131 "Reference: Name: ", ACPI_LV_INFO, _COMPONENT);
132 ACPI_DUMP_ENTRY (obj_desc->reference.object, ACPI_LV_INFO);
138 acpi_os_printf ("Reference: Index %p\n",
139 obj_desc->reference.object);
145 acpi_os_printf ("Reference: (ref_of) %p\n",
146 obj_desc->reference.object);
152 acpi_os_printf ("Reference: Arg%d",
153 obj_desc->reference.offset);
155 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
156 /* Value is an Integer */
158 acpi_os_printf (" value is [%8.8X%8.8x]",
159 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
162 acpi_os_printf ("\n");
168 acpi_os_printf ("Reference: Local%d",
169 obj_desc->reference.offset);
171 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
173 /* Value is an Integer */
175 acpi_os_printf (" value is [%8.8X%8.8x]",
176 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
179 acpi_os_printf ("\n");
183 case AML_INT_NAMEPATH_OP:
185 acpi_os_printf ("Reference.Node->Name %X\n",
186 obj_desc->reference.node->name.integer);
194 acpi_os_printf ("Unknown Reference opcode=%X\n",
195 obj_desc->reference.opcode);
202 case ACPI_TYPE_BUFFER:
204 acpi_os_printf ("Buffer len %X @ %p \n",
205 obj_desc->buffer.length, obj_desc->buffer.pointer);
207 length = obj_desc->buffer.length;
212 /* Debug only -- dump the buffer contents */
214 if (obj_desc->buffer.pointer) {
215 acpi_os_printf ("Buffer Contents: ");
217 for (index = 0; index < length; index++) {
218 acpi_os_printf (" %02x", obj_desc->buffer.pointer[index]);
220 acpi_os_printf ("\n");
225 case ACPI_TYPE_INTEGER:
227 acpi_os_printf ("Integer %8.8X%8.8X\n",
228 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
232 case ACPI_TYPE_PACKAGE:
234 acpi_os_printf ("Package [Len %X] element_array %p\n",
235 obj_desc->package.count, obj_desc->package.elements);
238 * If elements exist, package element pointer is valid,
239 * and debug_level exceeds 1, dump package's elements.
241 if (obj_desc->package.count &&
242 obj_desc->package.elements &&
243 acpi_dbg_level > 1) {
244 for (index = 0; index < obj_desc->package.count; index++) {
245 acpi_ex_dump_operand (obj_desc->package.elements[index], depth+1);
251 case ACPI_TYPE_REGION:
253 acpi_os_printf ("Region %s (%X)",
254 acpi_ut_get_region_name (obj_desc->region.space_id),
255 obj_desc->region.space_id);
258 * If the address and length have not been evaluated,
261 if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
262 acpi_os_printf ("\n");
265 acpi_os_printf (" base %8.8X%8.8X Length %X\n",
266 ACPI_FORMAT_UINT64 (obj_desc->region.address),
267 obj_desc->region.length);
272 case ACPI_TYPE_STRING:
274 acpi_os_printf ("String length %X @ %p ",
275 obj_desc->string.length, obj_desc->string.pointer);
276 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
277 acpi_os_printf ("\n");
281 case ACPI_TYPE_LOCAL_BANK_FIELD:
283 acpi_os_printf ("bank_field\n");
287 case ACPI_TYPE_LOCAL_REGION_FIELD:
290 "region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
291 obj_desc->field.bit_length, obj_desc->field.access_byte_width,
292 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
293 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
294 obj_desc->field.base_byte_offset, obj_desc->field.start_field_bit_offset);
295 acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1);
299 case ACPI_TYPE_LOCAL_INDEX_FIELD:
301 acpi_os_printf ("index_field\n");
305 case ACPI_TYPE_BUFFER_FIELD:
308 "buffer_field: %X bits at byte %X bit %X of \n",
309 obj_desc->buffer_field.bit_length, obj_desc->buffer_field.base_byte_offset,
310 obj_desc->buffer_field.start_field_bit_offset);
312 if (!obj_desc->buffer_field.buffer_obj) {
313 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n"));
315 else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != ACPI_TYPE_BUFFER) {
316 acpi_os_printf ("*not a Buffer* \n");
319 acpi_ex_dump_operand (obj_desc->buffer_field.buffer_obj, depth+1);
324 case ACPI_TYPE_EVENT:
326 acpi_os_printf ("Event\n");
330 case ACPI_TYPE_METHOD:
333 "Method(%X) @ %p:%X\n",
334 obj_desc->method.param_count,
335 obj_desc->method.aml_start, obj_desc->method.aml_length);
339 case ACPI_TYPE_MUTEX:
341 acpi_os_printf ("Mutex\n");
345 case ACPI_TYPE_DEVICE:
347 acpi_os_printf ("Device\n");
351 case ACPI_TYPE_POWER:
353 acpi_os_printf ("Power\n");
357 case ACPI_TYPE_PROCESSOR:
359 acpi_os_printf ("Processor\n");
363 case ACPI_TYPE_THERMAL:
365 acpi_os_printf ("Thermal\n");
372 acpi_os_printf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (obj_desc));
380 /*****************************************************************************
382 * FUNCTION: acpi_ex_dump_operands
384 * PARAMETERS: Operands - Operand list
385 * interpreter_mode - Load or Exec
386 * Ident - Identification
387 * num_levels - # of stack entries to dump above line
388 * Note - Output notation
389 * module_name - Caller's module name
390 * line_number - Caller's invocation line number
392 * DESCRIPTION: Dump the object stack
394 ****************************************************************************/
397 acpi_ex_dump_operands (
398 union acpi_operand_object **operands,
399 acpi_interpreter_mode interpreter_mode,
409 ACPI_FUNCTION_NAME ("ex_dump_operands");
420 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
421 "************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
424 if (num_levels == 0) {
428 /* Dump the operand stack starting at the top */
430 for (i = 0; num_levels > 0; i--, num_levels--) {
431 acpi_ex_dump_operand (operands[i], 0);
434 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
435 "************* Stack dump from %s(%d), %s\n",
436 module_name, line_number, note));
441 #ifdef ACPI_FUTURE_USAGE
443 /*****************************************************************************
445 * FUNCTION: acpi_ex_out*
447 * PARAMETERS: Title - Descriptive text
448 * Value - Value to be displayed
450 * DESCRIPTION: Object dump output formatting functions. These functions
451 * reduce the number of format strings required and keeps them
452 * all in one place for easy modification.
454 ****************************************************************************/
461 acpi_os_printf ("%20s : %s\n", title, value);
465 acpi_ex_out_pointer (
469 acpi_os_printf ("%20s : %p\n", title, value);
473 acpi_ex_out_integer (
477 acpi_os_printf ("%20s : %X\n", title, value);
481 acpi_ex_out_address (
483 acpi_physical_address value)
486 #if ACPI_MACHINE_WIDTH == 16
487 acpi_os_printf ("%20s : %p\n", title, value);
489 acpi_os_printf ("%20s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64 (value));
494 /*****************************************************************************
496 * FUNCTION: acpi_ex_dump_node
498 * PARAMETERS: *Node - Descriptor to dump
499 * Flags - Force display
501 * DESCRIPTION: Dumps the members of the given.Node
503 ****************************************************************************/
507 struct acpi_namespace_node *node,
511 ACPI_FUNCTION_ENTRY ();
515 if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
520 acpi_os_printf ("%20s : %4.4s\n", "Name", acpi_ut_get_node_name (node));
521 acpi_ex_out_string ("Type", acpi_ut_get_type_name (node->type));
522 acpi_ex_out_integer ("Flags", node->flags);
523 acpi_ex_out_integer ("Owner Id", node->owner_id);
524 acpi_ex_out_integer ("Reference Count", node->reference_count);
525 acpi_ex_out_pointer ("Attached Object", acpi_ns_get_attached_object (node));
526 acpi_ex_out_pointer ("child_list", node->child);
527 acpi_ex_out_pointer ("next_peer", node->peer);
528 acpi_ex_out_pointer ("Parent", acpi_ns_get_parent_node (node));
532 /*****************************************************************************
534 * FUNCTION: acpi_ex_dump_object_descriptor
536 * PARAMETERS: *Object - Descriptor to dump
537 * Flags - Force display
539 * DESCRIPTION: Dumps the members of the object descriptor given.
541 ****************************************************************************/
544 acpi_ex_dump_object_descriptor (
545 union acpi_operand_object *obj_desc,
551 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
555 if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
560 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
561 acpi_ex_dump_node ((struct acpi_namespace_node *) obj_desc, flags);
562 acpi_os_printf ("\nAttached Object (%p):\n",
563 ((struct acpi_namespace_node *) obj_desc)->object);
564 acpi_ex_dump_object_descriptor (
565 ((struct acpi_namespace_node *) obj_desc)->object, flags);
569 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
571 "ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n",
572 obj_desc, acpi_ut_get_descriptor_name (obj_desc));
578 acpi_ex_out_string ("Type", acpi_ut_get_object_type_name (obj_desc));
579 acpi_ex_out_integer ("Reference Count", obj_desc->common.reference_count);
580 acpi_ex_out_integer ("Flags", obj_desc->common.flags);
582 /* Object-specific Fields */
584 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
585 case ACPI_TYPE_INTEGER:
587 acpi_os_printf ("%20s : %8.8X%8.8X\n", "Value",
588 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
592 case ACPI_TYPE_STRING:
594 acpi_ex_out_integer ("Length", obj_desc->string.length);
596 acpi_os_printf ("%20s : %p ", "Pointer", obj_desc->string.pointer);
597 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
598 acpi_os_printf ("\n");
602 case ACPI_TYPE_BUFFER:
604 acpi_ex_out_integer ("Length", obj_desc->buffer.length);
605 acpi_ex_out_pointer ("Pointer", obj_desc->buffer.pointer);
606 ACPI_DUMP_BUFFER (obj_desc->buffer.pointer, obj_desc->buffer.length);
610 case ACPI_TYPE_PACKAGE:
612 acpi_ex_out_integer ("Flags", obj_desc->package.flags);
613 acpi_ex_out_integer ("Count", obj_desc->package.count);
614 acpi_ex_out_pointer ("Elements", obj_desc->package.elements);
616 /* Dump the package contents */
618 if (obj_desc->package.count > 0) {
619 acpi_os_printf ("\nPackage Contents:\n");
620 for (i = 0; i < obj_desc->package.count; i++) {
621 acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
622 if (obj_desc->package.elements[i]) {
623 acpi_os_printf (" %s",
624 acpi_ut_get_object_type_name (obj_desc->package.elements[i]));
626 acpi_os_printf ("\n");
632 case ACPI_TYPE_DEVICE:
634 acpi_ex_out_pointer ("Handler", obj_desc->device.handler);
635 acpi_ex_out_pointer ("system_notify", obj_desc->device.system_notify);
636 acpi_ex_out_pointer ("device_notify", obj_desc->device.device_notify);
640 case ACPI_TYPE_EVENT:
642 acpi_ex_out_pointer ("Semaphore", obj_desc->event.semaphore);
646 case ACPI_TYPE_METHOD:
648 acpi_ex_out_integer ("param_count", obj_desc->method.param_count);
649 acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency);
650 acpi_ex_out_pointer ("Semaphore", obj_desc->method.semaphore);
651 acpi_ex_out_integer ("owning_id", obj_desc->method.owning_id);
652 acpi_ex_out_integer ("aml_length", obj_desc->method.aml_length);
653 acpi_ex_out_pointer ("aml_start", obj_desc->method.aml_start);
657 case ACPI_TYPE_MUTEX:
659 acpi_ex_out_integer ("sync_level", obj_desc->mutex.sync_level);
660 acpi_ex_out_pointer ("owner_thread", obj_desc->mutex.owner_thread);
661 acpi_ex_out_integer ("acquire_depth", obj_desc->mutex.acquisition_depth);
662 acpi_ex_out_pointer ("Semaphore", obj_desc->mutex.semaphore);
666 case ACPI_TYPE_REGION:
668 acpi_ex_out_integer ("space_id", obj_desc->region.space_id);
669 acpi_ex_out_integer ("Flags", obj_desc->region.flags);
670 acpi_ex_out_address ("Address", obj_desc->region.address);
671 acpi_ex_out_integer ("Length", obj_desc->region.length);
672 acpi_ex_out_pointer ("Handler", obj_desc->region.handler);
673 acpi_ex_out_pointer ("Next", obj_desc->region.next);
677 case ACPI_TYPE_POWER:
679 acpi_ex_out_integer ("system_level", obj_desc->power_resource.system_level);
680 acpi_ex_out_integer ("resource_order", obj_desc->power_resource.resource_order);
681 acpi_ex_out_pointer ("system_notify", obj_desc->power_resource.system_notify);
682 acpi_ex_out_pointer ("device_notify", obj_desc->power_resource.device_notify);
686 case ACPI_TYPE_PROCESSOR:
688 acpi_ex_out_integer ("Processor ID", obj_desc->processor.proc_id);
689 acpi_ex_out_integer ("Length", obj_desc->processor.length);
690 acpi_ex_out_address ("Address", (acpi_physical_address) obj_desc->processor.address);
691 acpi_ex_out_pointer ("system_notify", obj_desc->processor.system_notify);
692 acpi_ex_out_pointer ("device_notify", obj_desc->processor.device_notify);
693 acpi_ex_out_pointer ("Handler", obj_desc->processor.handler);
697 case ACPI_TYPE_THERMAL:
699 acpi_ex_out_pointer ("system_notify", obj_desc->thermal_zone.system_notify);
700 acpi_ex_out_pointer ("device_notify", obj_desc->thermal_zone.device_notify);
701 acpi_ex_out_pointer ("Handler", obj_desc->thermal_zone.handler);
705 case ACPI_TYPE_BUFFER_FIELD:
706 case ACPI_TYPE_LOCAL_REGION_FIELD:
707 case ACPI_TYPE_LOCAL_BANK_FIELD:
708 case ACPI_TYPE_LOCAL_INDEX_FIELD:
710 acpi_ex_out_integer ("field_flags", obj_desc->common_field.field_flags);
711 acpi_ex_out_integer ("access_byte_width",obj_desc->common_field.access_byte_width);
712 acpi_ex_out_integer ("bit_length", obj_desc->common_field.bit_length);
713 acpi_ex_out_integer ("fld_bit_offset", obj_desc->common_field.start_field_bit_offset);
714 acpi_ex_out_integer ("base_byte_offset", obj_desc->common_field.base_byte_offset);
715 acpi_ex_out_integer ("datum_valid_bits", obj_desc->common_field.datum_valid_bits);
716 acpi_ex_out_integer ("end_fld_valid_bits",obj_desc->common_field.end_field_valid_bits);
717 acpi_ex_out_integer ("end_buf_valid_bits",obj_desc->common_field.end_buffer_valid_bits);
718 acpi_ex_out_pointer ("parent_node", obj_desc->common_field.node);
720 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
721 case ACPI_TYPE_BUFFER_FIELD:
722 acpi_ex_out_pointer ("buffer_obj", obj_desc->buffer_field.buffer_obj);
725 case ACPI_TYPE_LOCAL_REGION_FIELD:
726 acpi_ex_out_pointer ("region_obj", obj_desc->field.region_obj);
729 case ACPI_TYPE_LOCAL_BANK_FIELD:
730 acpi_ex_out_integer ("Value", obj_desc->bank_field.value);
731 acpi_ex_out_pointer ("region_obj", obj_desc->bank_field.region_obj);
732 acpi_ex_out_pointer ("bank_obj", obj_desc->bank_field.bank_obj);
735 case ACPI_TYPE_LOCAL_INDEX_FIELD:
736 acpi_ex_out_integer ("Value", obj_desc->index_field.value);
737 acpi_ex_out_pointer ("Index", obj_desc->index_field.index_obj);
738 acpi_ex_out_pointer ("Data", obj_desc->index_field.data_obj);
742 /* All object types covered above */
748 case ACPI_TYPE_LOCAL_REFERENCE:
750 acpi_ex_out_integer ("target_type", obj_desc->reference.target_type);
751 acpi_ex_out_string ("Opcode", (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name);
752 acpi_ex_out_integer ("Offset", obj_desc->reference.offset);
753 acpi_ex_out_pointer ("obj_desc", obj_desc->reference.object);
754 acpi_ex_out_pointer ("Node", obj_desc->reference.node);
755 acpi_ex_out_pointer ("Where", obj_desc->reference.where);
759 case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
761 acpi_ex_out_integer ("space_id", obj_desc->address_space.space_id);
762 acpi_ex_out_pointer ("Next", obj_desc->address_space.next);
763 acpi_ex_out_pointer ("region_list", obj_desc->address_space.region_list);
764 acpi_ex_out_pointer ("Node", obj_desc->address_space.node);
765 acpi_ex_out_pointer ("Context", obj_desc->address_space.context);
769 case ACPI_TYPE_LOCAL_NOTIFY:
771 acpi_ex_out_pointer ("Node", obj_desc->notify.node);
772 acpi_ex_out_pointer ("Context", obj_desc->notify.context);
776 case ACPI_TYPE_LOCAL_ALIAS:
777 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
778 case ACPI_TYPE_LOCAL_EXTRA:
779 case ACPI_TYPE_LOCAL_DATA:
783 "ex_dump_object_descriptor: Display not implemented for object type %s\n",
784 acpi_ut_get_object_type_name (obj_desc));
791 #endif /* ACPI_FUTURE_USAGE */