[ACPI] ACPICA 20050729 from Bob Moore
[deliverable/linux.git] / drivers / acpi / executer / exdump.c
index e2f7c32f28deb5a3a2af0b96deaeef030b556bec..4f98dceed39a620a9d6527a7d060488b73ac342c 100644 (file)
 #define _COMPONENT          ACPI_EXECUTER
         ACPI_MODULE_NAME    ("exdump")
 
-
 /*
  * The following routines are used for debug output only
  */
 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 
-/*****************************************************************************
+/* Local prototypes */
+
+#ifdef ACPI_FUTURE_USAGE
+static void
+acpi_ex_out_string (
+       char                            *title,
+       char                            *value);
+
+static void
+acpi_ex_out_pointer (
+       char                            *title,
+       void                            *value);
+
+static void
+acpi_ex_out_integer (
+       char                            *title,
+       u32                             value);
+
+static void
+acpi_ex_out_address (
+       char                            *title,
+       acpi_physical_address           value);
+
+static void
+acpi_ex_dump_reference (
+       union acpi_operand_object       *obj_desc);
+
+static void
+acpi_ex_dump_package (
+       union acpi_operand_object       *obj_desc,
+       u32                             level,
+       u32                             index);
+#endif /* ACPI_FUTURE_USAGE */
+
+/*******************************************************************************
  *
  * FUNCTION:    acpi_ex_dump_operand
  *
- * PARAMETERS:  *obj_desc         - Pointer to entry to be dumped
+ * PARAMETERS:  *obj_desc       - Pointer to entry to be dumped
+ *              Depth           - Current nesting depth
  *
  * RETURN:      None
  *
  * DESCRIPTION: Dump an operand object
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 void
 acpi_ex_dump_operand (
@@ -86,15 +120,14 @@ acpi_ex_dump_operand (
        }
 
        if (!obj_desc) {
-               /*
-                * This could be a null element of a package
-                */
+               /* This could be a null element of a package */
+
                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
                return;
        }
 
        if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
-               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is a NS Node: ", obj_desc));
+               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", obj_desc));
                ACPI_DUMP_ENTRY (obj_desc, ACPI_LV_EXEC);
                return;
        }
@@ -117,6 +150,8 @@ acpi_ex_dump_operand (
                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc));
        }
 
+       /* Decode object type */
+
        switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
        case ACPI_TYPE_LOCAL_REFERENCE:
 
@@ -274,7 +309,9 @@ acpi_ex_dump_operand (
        case ACPI_TYPE_STRING:
 
                acpi_os_printf ("String length %X @ %p ",
-                       obj_desc->string.length, obj_desc->string.pointer);
+                       obj_desc->string.length,
+                       obj_desc->string.pointer);
+
                acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
                acpi_os_printf ("\n");
                break;
@@ -290,10 +327,13 @@ acpi_ex_dump_operand (
 
                acpi_os_printf (
                        "region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
-                       obj_desc->field.bit_length, obj_desc->field.access_byte_width,
+                       obj_desc->field.bit_length,
+                       obj_desc->field.access_byte_width,
                        obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
                        obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
-                       obj_desc->field.base_byte_offset, obj_desc->field.start_field_bit_offset);
+                       obj_desc->field.base_byte_offset,
+                       obj_desc->field.start_field_bit_offset);
+
                acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1);
                break;
 
@@ -308,13 +348,15 @@ acpi_ex_dump_operand (
 
                acpi_os_printf (
                        "buffer_field: %X bits at byte %X bit %X of \n",
-                       obj_desc->buffer_field.bit_length, obj_desc->buffer_field.base_byte_offset,
+                       obj_desc->buffer_field.bit_length,
+                       obj_desc->buffer_field.base_byte_offset,
                        obj_desc->buffer_field.start_field_bit_offset);
 
                if (!obj_desc->buffer_field.buffer_obj) {
                        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n"));
                }
-               else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != ACPI_TYPE_BUFFER) {
+               else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) !=
+                                ACPI_TYPE_BUFFER) {
                        acpi_os_printf ("*not a Buffer* \n");
                }
                else {
@@ -331,10 +373,10 @@ acpi_ex_dump_operand (
 
        case ACPI_TYPE_METHOD:
 
-               acpi_os_printf (
-                       "Method(%X) @ %p:%X\n",
+               acpi_os_printf ("Method(%X) @ %p:%X\n",
                        obj_desc->method.param_count,
-                       obj_desc->method.aml_start, obj_desc->method.aml_length);
+                       obj_desc->method.aml_start,
+                       obj_desc->method.aml_length);
                break;
 
 
@@ -379,7 +421,7 @@ acpi_ex_dump_operand (
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
  * FUNCTION:    acpi_ex_dump_operands
  *
@@ -393,7 +435,7 @@ acpi_ex_dump_operand (
  *
  * DESCRIPTION: Dump the object stack
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 void
 acpi_ex_dump_operands (
@@ -434,17 +476,16 @@ acpi_ex_dump_operands (
        }
 
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-               "************* Stack dump from %s(%d), %s\n",
+               "************* Operand Stack dump from %s(%d), %s\n",
                module_name, line_number, note));
        return;
 }
 
 
 #ifdef ACPI_FUTURE_USAGE
-
-/*****************************************************************************
+/*******************************************************************************
  *
- * FUNCTION:    acpi_ex_out*
+ * FUNCTION:    acpi_ex_out* functions
  *
  * PARAMETERS:  Title               - Descriptive text
  *              Value               - Value to be displayed
@@ -453,9 +494,9 @@ acpi_ex_dump_operands (
  *              reduce the number of format strings required and keeps them
  *              all in one place for easy modification.
  *
- ****************************************************************************/
+ ******************************************************************************/
 
-void
+static void
 acpi_ex_out_string (
        char                            *title,
        char                            *value)
@@ -463,7 +504,7 @@ acpi_ex_out_string (
        acpi_os_printf ("%20s : %s\n", title, value);
 }
 
-void
+static void
 acpi_ex_out_pointer (
        char                            *title,
        void                            *value)
@@ -471,15 +512,15 @@ acpi_ex_out_pointer (
        acpi_os_printf ("%20s : %p\n", title, value);
 }
 
-void
+static void
 acpi_ex_out_integer (
        char                            *title,
        u32                             value)
 {
-       acpi_os_printf ("%20s : %X\n", title, value);
+       acpi_os_printf ("%20s : %.2X\n", title, value);
 }
 
-void
+static void
 acpi_ex_out_address (
        char                            *title,
        acpi_physical_address           value)
@@ -493,16 +534,16 @@ acpi_ex_out_address (
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
  * FUNCTION:    acpi_ex_dump_node
  *
  * PARAMETERS:  *Node               - Descriptor to dump
- *              Flags               - Force display
+ *              Flags               - Force display if TRUE
  *
  * DESCRIPTION: Dumps the members of the given.Node
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 void
 acpi_ex_dump_node (
@@ -531,28 +572,164 @@ acpi_ex_dump_node (
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_dump_reference
+ *
+ * PARAMETERS:  Object              - Descriptor to dump
+ *
+ * DESCRIPTION: Dumps a reference object
+ *
+ ******************************************************************************/
+
+static void
+acpi_ex_dump_reference (
+       union acpi_operand_object       *obj_desc)
+{
+       struct acpi_buffer              ret_buf;
+       acpi_status                     status;
+
+
+       if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
+               acpi_os_printf ("Named Object %p ", obj_desc->reference.node);
+               ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+               status = acpi_ns_handle_to_pathname (obj_desc->reference.node, &ret_buf);
+               if (ACPI_FAILURE (status)) {
+                       acpi_os_printf ("Could not convert name to pathname\n");
+               }
+               else {
+                  acpi_os_printf ("%s\n", (char *) ret_buf.pointer);
+                  ACPI_MEM_FREE (ret_buf.pointer);
+               }
+       }
+       else if (obj_desc->reference.object) {
+               acpi_os_printf ("\nReferenced Object: %p\n", obj_desc->reference.object);
+       }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ex_dump_package
+ *
+ * PARAMETERS:  Object              - Descriptor to dump
+ *              Level               - Indentation Level
+ *              Index               - Package index for this object
+ *
+ * DESCRIPTION: Dumps the elements of the package
+ *
+ ******************************************************************************/
+
+static void
+acpi_ex_dump_package (
+       union acpi_operand_object       *obj_desc,
+       u32                             level,
+       u32                             index)
+{
+       u32                             i;
+
+
+       /* Indentation and index output */
+
+       if (level > 0) {
+               for (i = 0; i < level; i++) {
+                       acpi_os_printf (" ");
+               }
+
+               acpi_os_printf ("[%.2d] ", index);
+       }
+
+       acpi_os_printf ("%p ", obj_desc);
+
+       /* Null package elements are allowed */
+
+       if (!obj_desc) {
+               acpi_os_printf ("[Null Object]\n");
+               return;
+       }
+
+       /* Packages may only contain a few object types */
+
+       switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
+       case ACPI_TYPE_INTEGER:
+
+               acpi_os_printf ("[Integer] = %8.8X%8.8X\n",
+                                ACPI_FORMAT_UINT64 (obj_desc->integer.value));
+               break;
+
+
+       case ACPI_TYPE_STRING:
+
+               acpi_os_printf ("[String] Value: ");
+               for (i = 0; i < obj_desc->string.length; i++) {
+                       acpi_os_printf ("%c", obj_desc->string.pointer[i]);
+               }
+               acpi_os_printf ("\n");
+               break;
+
+
+       case ACPI_TYPE_BUFFER:
+
+               acpi_os_printf ("[Buffer] Length %.2X = ", obj_desc->buffer.length);
+               if (obj_desc->buffer.length) {
+                       acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer,
+                                       obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT);
+               }
+               else {
+                       acpi_os_printf ("\n");
+               }
+               break;
+
+
+       case ACPI_TYPE_PACKAGE:
+
+               acpi_os_printf ("[Package] Contains %d Elements: \n",
+                               obj_desc->package.count);
+
+               for (i = 0; i < obj_desc->package.count; i++) {
+                       acpi_ex_dump_package (obj_desc->package.elements[i], level+1, i);
+               }
+               break;
+
+
+       case ACPI_TYPE_LOCAL_REFERENCE:
+
+               acpi_os_printf ("[Object Reference] ");
+               acpi_ex_dump_reference (obj_desc);
+               break;
+
+
+       default:
+
+               acpi_os_printf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (obj_desc));
+               break;
+       }
+}
+
+
+/*******************************************************************************
  *
  * FUNCTION:    acpi_ex_dump_object_descriptor
  *
- * PARAMETERS:  *Object             - Descriptor to dump
- *              Flags               - Force display
+ * PARAMETERS:  Object              - Descriptor to dump
+ *              Flags               - Force display if TRUE
  *
  * DESCRIPTION: Dumps the members of the object descriptor given.
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 void
 acpi_ex_dump_object_descriptor (
        union acpi_operand_object       *obj_desc,
        u32                             flags)
 {
-       u32                             i;
-
-
        ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
 
 
+       if (!obj_desc) {
+               return_VOID;
+       }
+
        if (!flags) {
                if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
                        return_VOID;
@@ -612,22 +789,13 @@ acpi_ex_dump_object_descriptor (
        case ACPI_TYPE_PACKAGE:
 
                acpi_ex_out_integer ("Flags",       obj_desc->package.flags);
-               acpi_ex_out_integer ("Count",       obj_desc->package.count);
-               acpi_ex_out_pointer ("Elements",    obj_desc->package.elements);
+               acpi_ex_out_integer ("Elements",    obj_desc->package.count);
+               acpi_ex_out_pointer ("Element List", obj_desc->package.elements);
 
                /* Dump the package contents */
 
-               if (obj_desc->package.count > 0) {
-                       acpi_os_printf ("\nPackage Contents:\n");
-                       for (i = 0; i < obj_desc->package.count; i++) {
-                               acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
-                               if (obj_desc->package.elements[i]) {
-                                       acpi_os_printf (" %s",
-                                               acpi_ut_get_object_type_name (obj_desc->package.elements[i]));
-                               }
-                               acpi_os_printf ("\n");
-                       }
-               }
+               acpi_os_printf ("\nPackage Contents:\n");
+               acpi_ex_dump_package (obj_desc, 0, 0);
                break;
 
 
@@ -650,7 +818,7 @@ acpi_ex_dump_object_descriptor (
                acpi_ex_out_integer ("param_count", obj_desc->method.param_count);
                acpi_ex_out_integer ("Concurrency", obj_desc->method.concurrency);
                acpi_ex_out_pointer ("Semaphore",   obj_desc->method.semaphore);
-               acpi_ex_out_integer ("owning_id",   obj_desc->method.owning_id);
+               acpi_ex_out_integer ("owner_id",    obj_desc->method.owner_id);
                acpi_ex_out_integer ("aml_length",  obj_desc->method.aml_length);
                acpi_ex_out_pointer ("aml_start",   obj_desc->method.aml_start);
                break;
@@ -747,11 +915,14 @@ acpi_ex_dump_object_descriptor (
        case ACPI_TYPE_LOCAL_REFERENCE:
 
                acpi_ex_out_integer ("target_type", obj_desc->reference.target_type);
-               acpi_ex_out_string ("Opcode",       (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name);
+               acpi_ex_out_string ("Opcode",       (acpi_ps_get_opcode_info (
+                                 obj_desc->reference.opcode))->name);
                acpi_ex_out_integer ("Offset",      obj_desc->reference.offset);
                acpi_ex_out_pointer ("obj_desc",    obj_desc->reference.object);
                acpi_ex_out_pointer ("Node",        obj_desc->reference.node);
                acpi_ex_out_pointer ("Where",       obj_desc->reference.where);
+
+               acpi_ex_dump_reference (obj_desc);
                break;
 
 
@@ -788,6 +959,5 @@ acpi_ex_dump_object_descriptor (
 }
 
 #endif  /*  ACPI_FUTURE_USAGE  */
-
 #endif
 
This page took 0.084773 seconds and 5 git commands to generate.