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
59 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
61 /*****************************************************************************
63 * FUNCTION: acpi_ex_dump_operand
65 * PARAMETERS: *obj_desc - Pointer to entry to be dumped
69 * DESCRIPTION: Dump an operand object
71 ****************************************************************************/
74 acpi_ex_dump_operand (
75 union acpi_operand_object *obj_desc)
79 union acpi_operand_object **element;
83 ACPI_FUNCTION_NAME ("ex_dump_operand")
86 if (!((ACPI_LV_EXEC & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
92 * This usually indicates that something serious is wrong
94 acpi_os_printf ("Null Object Descriptor\n");
98 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
99 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is a NS Node: ", obj_desc));
100 ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC);
104 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
105 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
106 "%p is not a node or operand object: [%s]\n",
107 obj_desc, acpi_ut_get_descriptor_name (obj_desc)));
108 ACPI_DUMP_BUFFER (obj_desc, sizeof (union acpi_operand_object));
112 /* obj_desc is a valid object */
114 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc));
116 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
117 case ACPI_TYPE_LOCAL_REFERENCE:
119 switch (obj_desc->reference.opcode) {
122 acpi_os_printf ("Reference: Debug\n");
128 ACPI_DUMP_PATHNAME (obj_desc->reference.object, "Reference: Name: ",
129 ACPI_LV_INFO, _COMPONENT);
130 ACPI_DUMP_ENTRY (obj_desc->reference.object, ACPI_LV_INFO);
136 acpi_os_printf ("Reference: Index %p\n",
137 obj_desc->reference.object);
143 acpi_os_printf ("Reference: (ref_of) %p\n",
144 obj_desc->reference.object);
150 acpi_os_printf ("Reference: Arg%d",
151 obj_desc->reference.offset);
153 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
154 /* Value is an Integer */
156 acpi_os_printf (" value is [%8.8X%8.8x]",
157 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
160 acpi_os_printf ("\n");
166 acpi_os_printf ("Reference: Local%d",
167 obj_desc->reference.offset);
169 if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
171 /* Value is an Integer */
173 acpi_os_printf (" value is [%8.8X%8.8x]",
174 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
177 acpi_os_printf ("\n");
181 case AML_INT_NAMEPATH_OP:
183 acpi_os_printf ("Reference.Node->Name %X\n",
184 obj_desc->reference.node->name.integer);
192 acpi_os_printf ("Unknown Reference opcode=%X\n",
193 obj_desc->reference.opcode);
201 case ACPI_TYPE_BUFFER:
203 acpi_os_printf ("Buffer len %X @ %p \n",
204 obj_desc->buffer.length,
205 obj_desc->buffer.pointer);
207 length = obj_desc->buffer.length;
213 /* Debug only -- dump the buffer contents */
215 if (obj_desc->buffer.pointer) {
216 acpi_os_printf ("Buffer Contents: ");
218 for (buf = obj_desc->buffer.pointer; length--; ++buf) {
219 acpi_os_printf (" %02x", *buf);
221 acpi_os_printf ("\n");
227 case ACPI_TYPE_INTEGER:
229 acpi_os_printf ("Integer %8.8X%8.8X\n",
230 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
234 case ACPI_TYPE_PACKAGE:
236 acpi_os_printf ("Package count %X @ %p\n",
237 obj_desc->package.count, obj_desc->package.elements);
240 * If elements exist, package vector pointer is valid,
241 * and debug_level exceeds 1, dump package's elements.
243 if (obj_desc->package.count &&
244 obj_desc->package.elements &&
245 acpi_dbg_level > 1) {
246 for (element_index = 0, element = obj_desc->package.elements;
247 element_index < obj_desc->package.count;
248 ++element_index, ++element) {
249 acpi_ex_dump_operand (*element);
252 acpi_os_printf ("\n");
256 case ACPI_TYPE_REGION:
258 acpi_os_printf ("Region %s (%X)",
259 acpi_ut_get_region_name (obj_desc->region.space_id),
260 obj_desc->region.space_id);
263 * If the address and length have not been evaluated,
266 if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
267 acpi_os_printf ("\n");
270 acpi_os_printf (" base %8.8X%8.8X Length %X\n",
271 ACPI_FORMAT_UINT64 (obj_desc->region.address),
272 obj_desc->region.length);
277 case ACPI_TYPE_STRING:
279 acpi_os_printf ("String length %X @ %p ",
280 obj_desc->string.length, obj_desc->string.pointer);
281 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
282 acpi_os_printf ("\n");
286 case ACPI_TYPE_LOCAL_BANK_FIELD:
288 acpi_os_printf ("bank_field\n");
292 case ACPI_TYPE_LOCAL_REGION_FIELD:
295 "region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
296 obj_desc->field.bit_length, obj_desc->field.access_byte_width,
297 obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
298 obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
299 obj_desc->field.base_byte_offset, obj_desc->field.start_field_bit_offset);
300 ACPI_DUMP_STACK_ENTRY (obj_desc->field.region_obj);
304 case ACPI_TYPE_LOCAL_INDEX_FIELD:
306 acpi_os_printf ("index_field\n");
310 case ACPI_TYPE_BUFFER_FIELD:
313 "buffer_field: %X bits at byte %X bit %X of \n",
314 obj_desc->buffer_field.bit_length, obj_desc->buffer_field.base_byte_offset,
315 obj_desc->buffer_field.start_field_bit_offset);
317 if (!obj_desc->buffer_field.buffer_obj) {
318 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n"));
320 else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != ACPI_TYPE_BUFFER) {
321 acpi_os_printf ("*not a Buffer* \n");
324 ACPI_DUMP_STACK_ENTRY (obj_desc->buffer_field.buffer_obj);
330 case ACPI_TYPE_EVENT:
332 acpi_os_printf ("Event\n");
336 case ACPI_TYPE_METHOD:
339 "Method(%X) @ %p:%X\n",
340 obj_desc->method.param_count,
341 obj_desc->method.aml_start, obj_desc->method.aml_length);
345 case ACPI_TYPE_MUTEX:
347 acpi_os_printf ("Mutex\n");
351 case ACPI_TYPE_DEVICE:
353 acpi_os_printf ("Device\n");
357 case ACPI_TYPE_POWER:
359 acpi_os_printf ("Power\n");
363 case ACPI_TYPE_PROCESSOR:
365 acpi_os_printf ("Processor\n");
369 case ACPI_TYPE_THERMAL:
371 acpi_os_printf ("Thermal\n");
378 acpi_os_printf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (obj_desc));
386 /*****************************************************************************
388 * FUNCTION: acpi_ex_dump_operands
390 * PARAMETERS: interpreter_mode - Load or Exec
391 * *Ident - Identification
392 * num_levels - # of stack entries to dump above line
393 * *Note - Output notation
395 * DESCRIPTION: Dump the object stack
397 ****************************************************************************/
400 acpi_ex_dump_operands (
401 union acpi_operand_object **operands,
402 acpi_interpreter_mode interpreter_mode,
410 union acpi_operand_object **obj_desc;
413 ACPI_FUNCTION_NAME ("ex_dump_operands");
424 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
425 "************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
428 if (num_levels == 0) {
432 /* Dump the operand stack starting at the top */
434 for (i = 0; num_levels > 0; i--, num_levels--) {
435 obj_desc = &operands[i];
436 acpi_ex_dump_operand (*obj_desc);
439 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
440 "************* Stack dump from %s(%d), %s\n",
441 module_name, line_number, note));
446 /*****************************************************************************
448 * FUNCTION: acpi_ex_out*
450 * PARAMETERS: Title - Descriptive text
451 * Value - Value to be displayed
453 * DESCRIPTION: Object dump output formatting functions. These functions
454 * reduce the number of format strings required and keeps them
455 * all in one place for easy modification.
457 ****************************************************************************/
464 acpi_os_printf ("%20s : %s\n", title, value);
468 acpi_ex_out_pointer (
472 acpi_os_printf ("%20s : %p\n", title, value);
476 acpi_ex_out_integer (
480 acpi_os_printf ("%20s : %X\n", title, value);
484 acpi_ex_out_address (
486 acpi_physical_address value)
489 #if ACPI_MACHINE_WIDTH == 16
490 acpi_os_printf ("%20s : %p\n", title, value);
492 acpi_os_printf ("%20s : %8.8X%8.8X\n", title,
493 ACPI_FORMAT_UINT64 (value));
498 /*****************************************************************************
500 * FUNCTION: acpi_ex_dump_node
502 * PARAMETERS: *Node - Descriptor to dump
503 * Flags - Force display
505 * DESCRIPTION: Dumps the members of the given.Node
507 ****************************************************************************/
511 struct acpi_namespace_node *node,
515 ACPI_FUNCTION_ENTRY ();
519 if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
524 acpi_os_printf ("%20s : %4.4s\n", "Name", acpi_ut_get_node_name (node));
525 acpi_ex_out_string ("Type", acpi_ut_get_type_name (node->type));
526 acpi_ex_out_integer ("Flags", node->flags);
527 acpi_ex_out_integer ("Owner Id", node->owner_id);
528 acpi_ex_out_integer ("Reference Count", node->reference_count);
529 acpi_ex_out_pointer ("Attached Object", acpi_ns_get_attached_object (node));
530 acpi_ex_out_pointer ("child_list", node->child);
531 acpi_ex_out_pointer ("next_peer", node->peer);
532 acpi_ex_out_pointer ("Parent", acpi_ns_get_parent_node (node));
536 /*****************************************************************************
538 * FUNCTION: acpi_ex_dump_object_descriptor
540 * PARAMETERS: *Object - Descriptor to dump
541 * Flags - Force display
543 * DESCRIPTION: Dumps the members of the object descriptor given.
545 ****************************************************************************/
548 acpi_ex_dump_object_descriptor (
549 union acpi_operand_object *obj_desc,
555 ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
559 if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
564 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
565 acpi_ex_dump_node ((struct acpi_namespace_node *) obj_desc, flags);
566 acpi_os_printf ("\nAttached Object (%p):\n", ((struct acpi_namespace_node *) obj_desc)->object);
567 acpi_ex_dump_object_descriptor (((struct acpi_namespace_node *) obj_desc)->object, flags);
571 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
572 acpi_os_printf ("ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n",
573 obj_desc, acpi_ut_get_descriptor_name (obj_desc));
579 acpi_ex_out_string ("Type", acpi_ut_get_object_type_name (obj_desc));
580 acpi_ex_out_integer ("Reference Count", obj_desc->common.reference_count);
581 acpi_ex_out_integer ("Flags", obj_desc->common.flags);
583 /* Object-specific Fields */
585 switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
586 case ACPI_TYPE_INTEGER:
588 acpi_os_printf ("%20s : %8.8X%8.8X\n", "Value",
589 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
593 case ACPI_TYPE_STRING:
595 acpi_ex_out_integer ("Length", obj_desc->string.length);
597 acpi_os_printf ("%20s : %p ", "Pointer", obj_desc->string.pointer);
598 acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
599 acpi_os_printf ("\n");
603 case ACPI_TYPE_BUFFER:
605 acpi_ex_out_integer ("Length", obj_desc->buffer.length);
606 acpi_ex_out_pointer ("Pointer", obj_desc->buffer.pointer);
607 ACPI_DUMP_BUFFER (obj_desc->buffer.pointer, obj_desc->buffer.length);
611 case ACPI_TYPE_PACKAGE:
613 acpi_ex_out_integer ("Flags", obj_desc->package.flags);
614 acpi_ex_out_integer ("Count", obj_desc->package.count);
615 acpi_ex_out_pointer ("Elements", obj_desc->package.elements);
617 /* Dump the package contents */
619 if (obj_desc->package.count > 0) {
620 acpi_os_printf ("\nPackage Contents:\n");
621 for (i = 0; i < obj_desc->package.count; i++) {
622 acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
623 if (obj_desc->package.elements[i]) {
624 acpi_os_printf (" %s", 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 ("acquisition_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:
782 acpi_os_printf ("ex_dump_object_descriptor: Display not implemented for object type %s\n",
783 acpi_ut_get_object_type_name (obj_desc));