Home | History | Annotate | Line # | Download | only in executer
exdebug.c revision 1.3.4.2
      1  1.3.4.2  rmind /******************************************************************************
      2  1.3.4.2  rmind  *
      3  1.3.4.2  rmind  * Module Name: exdebug - Support for stores to the AML Debug Object
      4  1.3.4.2  rmind  *
      5  1.3.4.2  rmind  *****************************************************************************/
      6  1.3.4.2  rmind 
      7  1.3.4.2  rmind /*
      8  1.3.4.2  rmind  * Copyright (C) 2000 - 2011, Intel Corp.
      9  1.3.4.2  rmind  * All rights reserved.
     10  1.3.4.2  rmind  *
     11  1.3.4.2  rmind  * Redistribution and use in source and binary forms, with or without
     12  1.3.4.2  rmind  * modification, are permitted provided that the following conditions
     13  1.3.4.2  rmind  * are met:
     14  1.3.4.2  rmind  * 1. Redistributions of source code must retain the above copyright
     15  1.3.4.2  rmind  *    notice, this list of conditions, and the following disclaimer,
     16  1.3.4.2  rmind  *    without modification.
     17  1.3.4.2  rmind  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.3.4.2  rmind  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.3.4.2  rmind  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.3.4.2  rmind  *    including a substantially similar Disclaimer requirement for further
     21  1.3.4.2  rmind  *    binary redistribution.
     22  1.3.4.2  rmind  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.3.4.2  rmind  *    of any contributors may be used to endorse or promote products derived
     24  1.3.4.2  rmind  *    from this software without specific prior written permission.
     25  1.3.4.2  rmind  *
     26  1.3.4.2  rmind  * Alternatively, this software may be distributed under the terms of the
     27  1.3.4.2  rmind  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.3.4.2  rmind  * Software Foundation.
     29  1.3.4.2  rmind  *
     30  1.3.4.2  rmind  * NO WARRANTY
     31  1.3.4.2  rmind  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.3.4.2  rmind  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.3.4.2  rmind  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.3.4.2  rmind  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.3.4.2  rmind  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.3.4.2  rmind  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.3.4.2  rmind  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.3.4.2  rmind  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.3.4.2  rmind  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.3.4.2  rmind  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.3.4.2  rmind  * POSSIBILITY OF SUCH DAMAGES.
     42  1.3.4.2  rmind  */
     43  1.3.4.2  rmind 
     44  1.3.4.2  rmind #define __EXDEBUG_C__
     45  1.3.4.2  rmind 
     46  1.3.4.2  rmind #include "acpi.h"
     47  1.3.4.2  rmind #include "accommon.h"
     48  1.3.4.2  rmind #include "acinterp.h"
     49  1.3.4.2  rmind 
     50  1.3.4.2  rmind 
     51  1.3.4.2  rmind #define _COMPONENT          ACPI_EXECUTER
     52  1.3.4.2  rmind         ACPI_MODULE_NAME    ("exdebug")
     53  1.3.4.2  rmind 
     54  1.3.4.2  rmind 
     55  1.3.4.2  rmind #ifndef ACPI_NO_ERROR_MESSAGES
     56  1.3.4.2  rmind /*******************************************************************************
     57  1.3.4.2  rmind  *
     58  1.3.4.2  rmind  * FUNCTION:    AcpiExDoDebugObject
     59  1.3.4.2  rmind  *
     60  1.3.4.2  rmind  * PARAMETERS:  SourceDesc          - Object to be output to "Debug Object"
     61  1.3.4.2  rmind  *              Level               - Indentation level (used for packages)
     62  1.3.4.2  rmind  *              Index               - Current package element, zero if not pkg
     63  1.3.4.2  rmind  *
     64  1.3.4.2  rmind  * RETURN:      None
     65  1.3.4.2  rmind  *
     66  1.3.4.2  rmind  * DESCRIPTION: Handles stores to the AML Debug Object. For example:
     67  1.3.4.2  rmind  *              Store(INT1, Debug)
     68  1.3.4.2  rmind  *
     69  1.3.4.2  rmind  * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
     70  1.3.4.2  rmind  *
     71  1.3.4.2  rmind  * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set.
     72  1.3.4.2  rmind  * Thus, in the normal operational case, stores to the debug object are
     73  1.3.4.2  rmind  * ignored but can be easily enabled if necessary.
     74  1.3.4.2  rmind  *
     75  1.3.4.2  rmind  ******************************************************************************/
     76  1.3.4.2  rmind 
     77  1.3.4.2  rmind void
     78  1.3.4.2  rmind AcpiExDoDebugObject (
     79  1.3.4.2  rmind     ACPI_OPERAND_OBJECT     *SourceDesc,
     80  1.3.4.2  rmind     UINT32                  Level,
     81  1.3.4.2  rmind     UINT32                  Index)
     82  1.3.4.2  rmind {
     83  1.3.4.2  rmind     UINT32                  i;
     84  1.3.4.2  rmind 
     85  1.3.4.2  rmind 
     86  1.3.4.2  rmind     ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
     87  1.3.4.2  rmind 
     88  1.3.4.2  rmind 
     89  1.3.4.2  rmind     /* Output must be enabled via the DebugObject global */
     90  1.3.4.2  rmind 
     91  1.3.4.2  rmind     if (!AcpiGbl_EnableAmlDebugObject)
     92  1.3.4.2  rmind     {
     93  1.3.4.2  rmind         return_VOID;
     94  1.3.4.2  rmind     }
     95  1.3.4.2  rmind 
     96  1.3.4.2  rmind     /*
     97  1.3.4.2  rmind      * Print line header as long as we are not in the middle of an
     98  1.3.4.2  rmind      * object display
     99  1.3.4.2  rmind      */
    100  1.3.4.2  rmind     if (!((Level > 0) && Index == 0))
    101  1.3.4.2  rmind     {
    102  1.3.4.2  rmind         AcpiOsPrintf ("[ACPI Debug] %*s", Level, " ");
    103  1.3.4.2  rmind     }
    104  1.3.4.2  rmind 
    105  1.3.4.2  rmind     /* Display the index for package output only */
    106  1.3.4.2  rmind 
    107  1.3.4.2  rmind     if (Index > 0)
    108  1.3.4.2  rmind     {
    109  1.3.4.2  rmind        AcpiOsPrintf ("(%.2u) ", Index-1);
    110  1.3.4.2  rmind     }
    111  1.3.4.2  rmind 
    112  1.3.4.2  rmind     if (!SourceDesc)
    113  1.3.4.2  rmind     {
    114  1.3.4.2  rmind         AcpiOsPrintf ("[Null Object]\n");
    115  1.3.4.2  rmind         return_VOID;
    116  1.3.4.2  rmind     }
    117  1.3.4.2  rmind 
    118  1.3.4.2  rmind     if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
    119  1.3.4.2  rmind     {
    120  1.3.4.2  rmind         AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
    121  1.3.4.2  rmind 
    122  1.3.4.2  rmind         if (!AcpiUtValidInternalObject (SourceDesc))
    123  1.3.4.2  rmind         {
    124  1.3.4.2  rmind            AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
    125  1.3.4.2  rmind            return_VOID;
    126  1.3.4.2  rmind         }
    127  1.3.4.2  rmind     }
    128  1.3.4.2  rmind     else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
    129  1.3.4.2  rmind     {
    130  1.3.4.2  rmind         AcpiOsPrintf ("%s: %p\n",
    131  1.3.4.2  rmind             AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
    132  1.3.4.2  rmind             SourceDesc);
    133  1.3.4.2  rmind         return_VOID;
    134  1.3.4.2  rmind     }
    135  1.3.4.2  rmind     else
    136  1.3.4.2  rmind     {
    137  1.3.4.2  rmind         return_VOID;
    138  1.3.4.2  rmind     }
    139  1.3.4.2  rmind 
    140  1.3.4.2  rmind     /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
    141  1.3.4.2  rmind 
    142  1.3.4.2  rmind     switch (SourceDesc->Common.Type)
    143  1.3.4.2  rmind     {
    144  1.3.4.2  rmind     case ACPI_TYPE_INTEGER:
    145  1.3.4.2  rmind 
    146  1.3.4.2  rmind         /* Output correct integer width */
    147  1.3.4.2  rmind 
    148  1.3.4.2  rmind         if (AcpiGbl_IntegerByteWidth == 4)
    149  1.3.4.2  rmind         {
    150  1.3.4.2  rmind             AcpiOsPrintf ("0x%8.8X\n",
    151  1.3.4.2  rmind                 (UINT32) SourceDesc->Integer.Value);
    152  1.3.4.2  rmind         }
    153  1.3.4.2  rmind         else
    154  1.3.4.2  rmind         {
    155  1.3.4.2  rmind             AcpiOsPrintf ("0x%8.8X%8.8X\n",
    156  1.3.4.2  rmind                 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
    157  1.3.4.2  rmind         }
    158  1.3.4.2  rmind         break;
    159  1.3.4.2  rmind 
    160  1.3.4.2  rmind     case ACPI_TYPE_BUFFER:
    161  1.3.4.2  rmind 
    162  1.3.4.2  rmind         AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
    163  1.3.4.2  rmind         AcpiUtDumpBuffer2 (SourceDesc->Buffer.Pointer,
    164  1.3.4.2  rmind             (SourceDesc->Buffer.Length < 256) ?
    165  1.3.4.2  rmind                 SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY);
    166  1.3.4.2  rmind         break;
    167  1.3.4.2  rmind 
    168  1.3.4.2  rmind     case ACPI_TYPE_STRING:
    169  1.3.4.2  rmind 
    170  1.3.4.2  rmind         AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
    171  1.3.4.2  rmind             SourceDesc->String.Length, SourceDesc->String.Pointer);
    172  1.3.4.2  rmind         break;
    173  1.3.4.2  rmind 
    174  1.3.4.2  rmind     case ACPI_TYPE_PACKAGE:
    175  1.3.4.2  rmind 
    176  1.3.4.2  rmind         AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
    177  1.3.4.2  rmind             SourceDesc->Package.Count);
    178  1.3.4.2  rmind 
    179  1.3.4.2  rmind         /* Output the entire contents of the package */
    180  1.3.4.2  rmind 
    181  1.3.4.2  rmind         for (i = 0; i < SourceDesc->Package.Count; i++)
    182  1.3.4.2  rmind         {
    183  1.3.4.2  rmind             AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
    184  1.3.4.2  rmind                 Level+4, i+1);
    185  1.3.4.2  rmind         }
    186  1.3.4.2  rmind         break;
    187  1.3.4.2  rmind 
    188  1.3.4.2  rmind     case ACPI_TYPE_LOCAL_REFERENCE:
    189  1.3.4.2  rmind 
    190  1.3.4.2  rmind         AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
    191  1.3.4.2  rmind 
    192  1.3.4.2  rmind         /* Decode the reference */
    193  1.3.4.2  rmind 
    194  1.3.4.2  rmind         switch (SourceDesc->Reference.Class)
    195  1.3.4.2  rmind         {
    196  1.3.4.2  rmind         case ACPI_REFCLASS_INDEX:
    197  1.3.4.2  rmind 
    198  1.3.4.2  rmind             AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
    199  1.3.4.2  rmind             break;
    200  1.3.4.2  rmind 
    201  1.3.4.2  rmind         case ACPI_REFCLASS_TABLE:
    202  1.3.4.2  rmind 
    203  1.3.4.2  rmind             /* Case for DdbHandle */
    204  1.3.4.2  rmind 
    205  1.3.4.2  rmind             AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
    206  1.3.4.2  rmind             return;
    207  1.3.4.2  rmind 
    208  1.3.4.2  rmind         default:
    209  1.3.4.2  rmind             break;
    210  1.3.4.2  rmind         }
    211  1.3.4.2  rmind 
    212  1.3.4.2  rmind         AcpiOsPrintf ("  ");
    213  1.3.4.2  rmind 
    214  1.3.4.2  rmind         /* Check for valid node first, then valid object */
    215  1.3.4.2  rmind 
    216  1.3.4.2  rmind         if (SourceDesc->Reference.Node)
    217  1.3.4.2  rmind         {
    218  1.3.4.2  rmind             if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
    219  1.3.4.2  rmind                     ACPI_DESC_TYPE_NAMED)
    220  1.3.4.2  rmind             {
    221  1.3.4.2  rmind                 AcpiOsPrintf (" %p - Not a valid namespace node\n",
    222  1.3.4.2  rmind                     SourceDesc->Reference.Node);
    223  1.3.4.2  rmind             }
    224  1.3.4.2  rmind             else
    225  1.3.4.2  rmind             {
    226  1.3.4.2  rmind                 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
    227  1.3.4.2  rmind                     (SourceDesc->Reference.Node)->Name.Ascii);
    228  1.3.4.2  rmind 
    229  1.3.4.2  rmind                 switch ((SourceDesc->Reference.Node)->Type)
    230  1.3.4.2  rmind                 {
    231  1.3.4.2  rmind                 /* These types have no attached object */
    232  1.3.4.2  rmind 
    233  1.3.4.2  rmind                 case ACPI_TYPE_DEVICE:
    234  1.3.4.2  rmind                     AcpiOsPrintf ("Device\n");
    235  1.3.4.2  rmind                     break;
    236  1.3.4.2  rmind 
    237  1.3.4.2  rmind                 case ACPI_TYPE_THERMAL:
    238  1.3.4.2  rmind                     AcpiOsPrintf ("Thermal Zone\n");
    239  1.3.4.2  rmind                     break;
    240  1.3.4.2  rmind 
    241  1.3.4.2  rmind                 default:
    242  1.3.4.2  rmind                     AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
    243  1.3.4.2  rmind                         Level+4, 0);
    244  1.3.4.2  rmind                     break;
    245  1.3.4.2  rmind                 }
    246  1.3.4.2  rmind             }
    247  1.3.4.2  rmind         }
    248  1.3.4.2  rmind         else if (SourceDesc->Reference.Object)
    249  1.3.4.2  rmind         {
    250  1.3.4.2  rmind             if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
    251  1.3.4.2  rmind                     ACPI_DESC_TYPE_NAMED)
    252  1.3.4.2  rmind             {
    253  1.3.4.2  rmind                 AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
    254  1.3.4.2  rmind                     SourceDesc->Reference.Object)->Object,
    255  1.3.4.2  rmind                     Level+4, 0);
    256  1.3.4.2  rmind             }
    257  1.3.4.2  rmind             else
    258  1.3.4.2  rmind             {
    259  1.3.4.2  rmind                 AcpiExDoDebugObject (SourceDesc->Reference.Object,
    260  1.3.4.2  rmind                     Level+4, 0);
    261  1.3.4.2  rmind             }
    262  1.3.4.2  rmind         }
    263  1.3.4.2  rmind         break;
    264  1.3.4.2  rmind 
    265  1.3.4.2  rmind     default:
    266  1.3.4.2  rmind 
    267  1.3.4.2  rmind         AcpiOsPrintf ("%p\n", SourceDesc);
    268  1.3.4.2  rmind         break;
    269  1.3.4.2  rmind     }
    270  1.3.4.2  rmind 
    271  1.3.4.2  rmind     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
    272  1.3.4.2  rmind     return_VOID;
    273  1.3.4.2  rmind }
    274  1.3.4.2  rmind #endif
    275  1.3.4.2  rmind 
    276  1.3.4.2  rmind 
    277