Subversion Repositories Kolibri OS

Rev

Rev 1498 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*******************************************************************************
  2.  *
  3.  * Module Name: dbdisply - debug display commands
  4.  *
  5.  ******************************************************************************/
  6.  
  7. /******************************************************************************
  8.  *
  9.  * 1. Copyright Notice
  10.  *
  11.  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
  12.  * All rights reserved.
  13.  *
  14.  * 2. License
  15.  *
  16.  * 2.1. This is your license from Intel Corp. under its intellectual property
  17.  * rights.  You may have additional license terms from the party that provided
  18.  * you this software, covering your right to use that party's intellectual
  19.  * property rights.
  20.  *
  21.  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
  22.  * copy of the source code appearing in this file ("Covered Code") an
  23.  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
  24.  * base code distributed originally by Intel ("Original Intel Code") to copy,
  25.  * make derivatives, distribute, use and display any portion of the Covered
  26.  * Code in any form, with the right to sublicense such rights; and
  27.  *
  28.  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
  29.  * license (with the right to sublicense), under only those claims of Intel
  30.  * patents that are infringed by the Original Intel Code, to make, use, sell,
  31.  * offer to sell, and import the Covered Code and derivative works thereof
  32.  * solely to the minimum extent necessary to exercise the above copyright
  33.  * license, and in no event shall the patent license extend to any additions
  34.  * to or modifications of the Original Intel Code.  No other license or right
  35.  * is granted directly or by implication, estoppel or otherwise;
  36.  *
  37.  * The above copyright and patent license is granted only if the following
  38.  * conditions are met:
  39.  *
  40.  * 3. Conditions
  41.  *
  42.  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
  43.  * Redistribution of source code of any substantial portion of the Covered
  44.  * Code or modification with rights to further distribute source must include
  45.  * the above Copyright Notice, the above License, this list of Conditions,
  46.  * and the following Disclaimer and Export Compliance provision.  In addition,
  47.  * Licensee must cause all Covered Code to which Licensee contributes to
  48.  * contain a file documenting the changes Licensee made to create that Covered
  49.  * Code and the date of any change.  Licensee must include in that file the
  50.  * documentation of any changes made by any predecessor Licensee.  Licensee
  51.  * must include a prominent statement that the modification is derived,
  52.  * directly or indirectly, from Original Intel Code.
  53.  *
  54.  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
  55.  * Redistribution of source code of any substantial portion of the Covered
  56.  * Code or modification without rights to further distribute source must
  57.  * include the following Disclaimer and Export Compliance provision in the
  58.  * documentation and/or other materials provided with distribution.  In
  59.  * addition, Licensee may not authorize further sublicense of source of any
  60.  * portion of the Covered Code, and must include terms to the effect that the
  61.  * license from Licensee to its licensee is limited to the intellectual
  62.  * property embodied in the software Licensee provides to its licensee, and
  63.  * not to intellectual property embodied in modifications its licensee may
  64.  * make.
  65.  *
  66.  * 3.3. Redistribution of Executable. Redistribution in executable form of any
  67.  * substantial portion of the Covered Code or modification must reproduce the
  68.  * above Copyright Notice, and the following Disclaimer and Export Compliance
  69.  * provision in the documentation and/or other materials provided with the
  70.  * distribution.
  71.  *
  72.  * 3.4. Intel retains all right, title, and interest in and to the Original
  73.  * Intel Code.
  74.  *
  75.  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
  76.  * Intel shall be used in advertising or otherwise to promote the sale, use or
  77.  * other dealings in products derived from or relating to the Covered Code
  78.  * without prior written authorization from Intel.
  79.  *
  80.  * 4. Disclaimer and Export Compliance
  81.  *
  82.  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
  83.  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
  84.  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
  85.  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
  86.  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
  87.  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
  88.  * PARTICULAR PURPOSE.
  89.  *
  90.  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
  91.  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
  92.  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
  93.  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
  94.  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
  95.  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
  96.  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
  97.  * LIMITED REMEDY.
  98.  *
  99.  * 4.3. Licensee shall not export, either directly or indirectly, any of this
  100.  * software or system incorporating such software without first obtaining any
  101.  * required license or other approval from the U. S. Department of Commerce or
  102.  * any other agency or department of the United States Government.  In the
  103.  * event Licensee exports any such software from the United States or
  104.  * re-exports any such software from a foreign destination, Licensee shall
  105.  * ensure that the distribution and export/re-export of the software is in
  106.  * compliance with all laws, regulations, orders, or other restrictions of the
  107.  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
  108.  * any of its subsidiaries will export/re-export any technical data, process,
  109.  * software, or service, directly or indirectly, to any country for which the
  110.  * United States government or any agency thereof requires an export license,
  111.  * other governmental approval, or letter of assurance, without first obtaining
  112.  * such license, approval or letter.
  113.  *
  114.  *****************************************************************************/
  115.  
  116.  
  117. #include "acpi.h"
  118. #include "accommon.h"
  119. #include "amlcode.h"
  120. #include "acdispat.h"
  121. #include "acnamesp.h"
  122. #include "acparser.h"
  123. #include "acinterp.h"
  124. #include "acdebug.h"
  125. #include "acdisasm.h"
  126.  
  127.  
  128. #ifdef ACPI_DEBUGGER
  129.  
  130. #define _COMPONENT          ACPI_CA_DEBUGGER
  131.         ACPI_MODULE_NAME    ("dbdisply")
  132.  
  133. /* Local prototypes */
  134.  
  135. static void
  136. AcpiDbDumpParserDescriptor (
  137.     ACPI_PARSE_OBJECT       *Op);
  138.  
  139. static void *
  140. AcpiDbGetPointer (
  141.     void                    *Target);
  142.  
  143.  
  144. /*
  145.  * System handler information.
  146.  * Used for Handlers command, in AcpiDbDisplayHandlers.
  147.  */
  148. #define ACPI_PREDEFINED_PREFIX          "%25s (%.2X) : "
  149. #define ACPI_HANDLER_NAME_STRING               "%30s : "
  150. #define ACPI_HANDLER_PRESENT_STRING                    "%-9s (%p)\n"
  151. #define ACPI_HANDLER_NOT_PRESENT_STRING                "%-9s\n"
  152.  
  153. /* All predefined Address Space IDs */
  154.  
  155. static ACPI_ADR_SPACE_TYPE  AcpiGbl_SpaceIdList[] =
  156. {
  157.     ACPI_ADR_SPACE_SYSTEM_MEMORY,
  158.     ACPI_ADR_SPACE_SYSTEM_IO,
  159.     ACPI_ADR_SPACE_PCI_CONFIG,
  160.     ACPI_ADR_SPACE_EC,
  161.     ACPI_ADR_SPACE_SMBUS,
  162.     ACPI_ADR_SPACE_CMOS,
  163.     ACPI_ADR_SPACE_PCI_BAR_TARGET,
  164.     ACPI_ADR_SPACE_IPMI,
  165.     ACPI_ADR_SPACE_DATA_TABLE,
  166.     ACPI_ADR_SPACE_FIXED_HARDWARE
  167. };
  168.  
  169. /* Global handler information */
  170.  
  171. typedef struct acpi_handler_info
  172. {
  173.     void                    *Handler;
  174.     char                    *Name;
  175.  
  176. } ACPI_HANDLER_INFO;
  177.  
  178. static ACPI_HANDLER_INFO    AcpiGbl_HandlerList[] =
  179. {
  180.     {&AcpiGbl_SystemNotify.Handler,     "System Notifications"},
  181.     {&AcpiGbl_DeviceNotify.Handler,     "Device Notifications"},
  182.     {&AcpiGbl_TableHandler,             "ACPI Table Events"},
  183.     {&AcpiGbl_ExceptionHandler,         "Control Method Exceptions"},
  184.     {&AcpiGbl_InterfaceHandler,         "OSI Invocations"}
  185. };
  186.  
  187.  
  188. /*******************************************************************************
  189.  *
  190.  * FUNCTION:    AcpiDbGetPointer
  191.  *
  192.  * PARAMETERS:  Target          - Pointer to string to be converted
  193.  *
  194.  * RETURN:      Converted pointer
  195.  *
  196.  * DESCRIPTION: Convert an ascii pointer value to a real value
  197.  *
  198.  ******************************************************************************/
  199.  
  200. static void *
  201. AcpiDbGetPointer (
  202.     void                    *Target)
  203. {
  204.     void                    *ObjPtr;
  205.  
  206.  
  207.     ObjPtr = ACPI_TO_POINTER (ACPI_STRTOUL (Target, NULL, 16));
  208.     return (ObjPtr);
  209. }
  210.  
  211.  
  212. /*******************************************************************************
  213.  *
  214.  * FUNCTION:    AcpiDbDumpParserDescriptor
  215.  *
  216.  * PARAMETERS:  Op              - A parser Op descriptor
  217.  *
  218.  * RETURN:      None
  219.  *
  220.  * DESCRIPTION: Display a formatted parser object
  221.  *
  222.  ******************************************************************************/
  223.  
  224. static void
  225. AcpiDbDumpParserDescriptor (
  226.     ACPI_PARSE_OBJECT       *Op)
  227. {
  228.     const ACPI_OPCODE_INFO  *Info;
  229.  
  230.  
  231.     Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
  232.  
  233.     AcpiOsPrintf ("Parser Op Descriptor:\n");
  234.     AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode);
  235.  
  236.     ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name",
  237.         Info->Name));
  238.  
  239.     AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg);
  240.     AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent);
  241.     AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next);
  242. }
  243.  
  244.  
  245. /*******************************************************************************
  246.  *
  247.  * FUNCTION:    AcpiDbDecodeAndDisplayObject
  248.  *
  249.  * PARAMETERS:  Target          - String with object to be displayed.  Names
  250.  *                                and hex pointers are supported.
  251.  *              OutputType      - Byte, Word, Dword, or Qword (B|W|D|Q)
  252.  *
  253.  * RETURN:      None
  254.  *
  255.  * DESCRIPTION: Display a formatted ACPI object
  256.  *
  257.  ******************************************************************************/
  258.  
  259. void
  260. AcpiDbDecodeAndDisplayObject (
  261.     char                    *Target,
  262.     char                    *OutputType)
  263. {
  264.     void                    *ObjPtr;
  265.     ACPI_NAMESPACE_NODE     *Node;
  266.     ACPI_OPERAND_OBJECT     *ObjDesc;
  267.     UINT32                  Display = DB_BYTE_DISPLAY;
  268.     char                    Buffer[80];
  269.     ACPI_BUFFER             RetBuf;
  270.     ACPI_STATUS             Status;
  271.     UINT32                  Size;
  272.  
  273.  
  274.     if (!Target)
  275.     {
  276.         return;
  277.     }
  278.  
  279.     /* Decode the output type */
  280.  
  281.     if (OutputType)
  282.     {
  283.         AcpiUtStrupr (OutputType);
  284.         if (OutputType[0] == 'W')
  285.         {
  286.             Display = DB_WORD_DISPLAY;
  287.         }
  288.         else if (OutputType[0] == 'D')
  289.         {
  290.             Display = DB_DWORD_DISPLAY;
  291.         }
  292.         else if (OutputType[0] == 'Q')
  293.         {
  294.             Display = DB_QWORD_DISPLAY;
  295.         }
  296.     }
  297.  
  298.     RetBuf.Length = sizeof (Buffer);
  299.     RetBuf.Pointer = Buffer;
  300.  
  301.     /* Differentiate between a number and a name */
  302.  
  303.     if ((Target[0] >= 0x30) && (Target[0] <= 0x39))
  304.     {
  305.         ObjPtr = AcpiDbGetPointer (Target);
  306.         if (!AcpiOsReadable (ObjPtr, 16))
  307.         {
  308.             AcpiOsPrintf ("Address %p is invalid in this address space\n",
  309.                 ObjPtr);
  310.             return;
  311.         }
  312.  
  313.         /* Decode the object type */
  314.  
  315.         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr))
  316.         {
  317.         case ACPI_DESC_TYPE_NAMED:
  318.  
  319.             /* This is a namespace Node */
  320.  
  321.             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
  322.             {
  323.                 AcpiOsPrintf (
  324.                     "Cannot read entire Named object at address %p\n", ObjPtr);
  325.                 return;
  326.             }
  327.  
  328.             Node = ObjPtr;
  329.             goto DumpNode;
  330.  
  331.  
  332.         case ACPI_DESC_TYPE_OPERAND:
  333.  
  334.             /* This is a ACPI OPERAND OBJECT */
  335.  
  336.             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
  337.             {
  338.                 AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n",
  339.                     ObjPtr);
  340.                 return;
  341.             }
  342.  
  343.             AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display,
  344.                 ACPI_UINT32_MAX);
  345.             AcpiExDumpObjectDescriptor (ObjPtr, 1);
  346.             break;
  347.  
  348.  
  349.         case ACPI_DESC_TYPE_PARSER:
  350.  
  351.             /* This is a Parser Op object */
  352.  
  353.             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
  354.             {
  355.                 AcpiOsPrintf (
  356.                     "Cannot read entire Parser object at address %p\n", ObjPtr);
  357.                 return;
  358.             }
  359.  
  360.             AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display,
  361.                 ACPI_UINT32_MAX);
  362.             AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
  363.             break;
  364.  
  365.  
  366.         default:
  367.  
  368.             /* Is not a recognizeable object */
  369.  
  370.             Size = 16;
  371.             if (AcpiOsReadable (ObjPtr, 64))
  372.             {
  373.                 Size = 64;
  374.             }
  375.  
  376.             /* Just dump some memory */
  377.  
  378.             AcpiUtDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
  379.             break;
  380.         }
  381.  
  382.         return;
  383.     }
  384.  
  385.     /* The parameter is a name string that must be resolved to a Named obj */
  386.  
  387.     Node = AcpiDbLocalNsLookup (Target);
  388.     if (!Node)
  389.     {
  390.         return;
  391.     }
  392.  
  393.  
  394. DumpNode:
  395.     /* Now dump the NS node */
  396.  
  397.     Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf);
  398.     if (ACPI_FAILURE (Status))
  399.     {
  400.         AcpiOsPrintf ("Could not convert name to pathname\n");
  401.     }
  402.  
  403.     else
  404.     {
  405.         AcpiOsPrintf ("Object (%p) Pathname:  %s\n",
  406.             Node, (char *) RetBuf.Pointer);
  407.     }
  408.  
  409.     if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
  410.     {
  411.         AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
  412.         return;
  413.     }
  414.  
  415.     AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE),
  416.         Display, ACPI_UINT32_MAX);
  417.     AcpiExDumpNamespaceNode (Node, 1);
  418.  
  419.     ObjDesc = AcpiNsGetAttachedObject (Node);
  420.     if (ObjDesc)
  421.     {
  422.         AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc);
  423.         if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))
  424.         {
  425.             AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n",
  426.                 ObjDesc);
  427.             return;
  428.         }
  429.  
  430.         AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT),
  431.             Display, ACPI_UINT32_MAX);
  432.         AcpiExDumpObjectDescriptor (ObjDesc, 1);
  433.     }
  434. }
  435.  
  436.  
  437. /*******************************************************************************
  438.  *
  439.  * FUNCTION:    AcpiDbDisplayMethodInfo
  440.  *
  441.  * PARAMETERS:  StartOp         - Root of the control method parse tree
  442.  *
  443.  * RETURN:      None
  444.  *
  445.  * DESCRIPTION: Display information about the current method
  446.  *
  447.  ******************************************************************************/
  448.  
  449. void
  450. AcpiDbDisplayMethodInfo (
  451.     ACPI_PARSE_OBJECT       *StartOp)
  452. {
  453.     ACPI_WALK_STATE         *WalkState;
  454.     ACPI_OPERAND_OBJECT     *ObjDesc;
  455.     ACPI_NAMESPACE_NODE     *Node;
  456.     ACPI_PARSE_OBJECT       *RootOp;
  457.     ACPI_PARSE_OBJECT       *Op;
  458.     const ACPI_OPCODE_INFO  *OpInfo;
  459.     UINT32                  NumOps = 0;
  460.     UINT32                  NumOperands = 0;
  461.     UINT32                  NumOperators = 0;
  462.     UINT32                  NumRemainingOps = 0;
  463.     UINT32                  NumRemainingOperands = 0;
  464.     UINT32                  NumRemainingOperators = 0;
  465.     BOOLEAN                 CountRemaining = FALSE;
  466.  
  467.  
  468.     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
  469.     if (!WalkState)
  470.     {
  471.         AcpiOsPrintf ("There is no method currently executing\n");
  472.         return;
  473.     }
  474.  
  475.     ObjDesc = WalkState->MethodDesc;
  476.     Node    = WalkState->MethodNode;
  477.  
  478.     AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",
  479.             AcpiUtGetNodeName (Node));
  480.     AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",
  481.             (UINT32) ObjDesc->Method.ParamCount,
  482.             (UINT32) ObjDesc->Method.SyncLevel);
  483.  
  484.  
  485.     RootOp = StartOp;
  486.     while (RootOp->Common.Parent)
  487.     {
  488.         RootOp = RootOp->Common.Parent;
  489.     }
  490.  
  491.     Op = RootOp;
  492.  
  493.     while (Op)
  494.     {
  495.         if (Op == StartOp)
  496.         {
  497.             CountRemaining = TRUE;
  498.         }
  499.  
  500.         NumOps++;
  501.         if (CountRemaining)
  502.         {
  503.             NumRemainingOps++;
  504.         }
  505.  
  506.         /* Decode the opcode */
  507.  
  508.         OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
  509.         switch (OpInfo->Class)
  510.         {
  511.         case AML_CLASS_ARGUMENT:
  512.             if (CountRemaining)
  513.             {
  514.                 NumRemainingOperands++;
  515.             }
  516.  
  517.             NumOperands++;
  518.             break;
  519.  
  520.         case AML_CLASS_UNKNOWN:
  521.             /* Bad opcode or ASCII character */
  522.  
  523.             continue;
  524.  
  525.         default:
  526.             if (CountRemaining)
  527.             {
  528.                 NumRemainingOperators++;
  529.             }
  530.  
  531.             NumOperators++;
  532.             break;
  533.         }
  534.  
  535.         Op = AcpiPsGetDepthNext (StartOp, Op);
  536.     }
  537.  
  538.     AcpiOsPrintf (
  539.         "Method contains:       %X AML Opcodes - %X Operators, %X Operands\n",
  540.         NumOps, NumOperators, NumOperands);
  541.  
  542.     AcpiOsPrintf (
  543.         "Remaining to execute:  %X AML Opcodes - %X Operators, %X Operands\n",
  544.         NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
  545. }
  546.  
  547.  
  548. /*******************************************************************************
  549.  *
  550.  * FUNCTION:    AcpiDbDisplayLocals
  551.  *
  552.  * PARAMETERS:  None
  553.  *
  554.  * RETURN:      None
  555.  *
  556.  * DESCRIPTION: Display all locals for the currently running control method
  557.  *
  558.  ******************************************************************************/
  559.  
  560. void
  561. AcpiDbDisplayLocals (
  562.     void)
  563. {
  564.     ACPI_WALK_STATE         *WalkState;
  565.  
  566.  
  567.     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
  568.     if (!WalkState)
  569.     {
  570.         AcpiOsPrintf ("There is no method currently executing\n");
  571.         return;
  572.     }
  573.  
  574.     AcpiDmDisplayLocals (WalkState);
  575. }
  576.  
  577.  
  578. /*******************************************************************************
  579.  *
  580.  * FUNCTION:    AcpiDbDisplayArguments
  581.  *
  582.  * PARAMETERS:  None
  583.  *
  584.  * RETURN:      None
  585.  *
  586.  * DESCRIPTION: Display all arguments for the currently running control method
  587.  *
  588.  ******************************************************************************/
  589.  
  590. void
  591. AcpiDbDisplayArguments (
  592.     void)
  593. {
  594.     ACPI_WALK_STATE         *WalkState;
  595.  
  596.  
  597.     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
  598.     if (!WalkState)
  599.     {
  600.         AcpiOsPrintf ("There is no method currently executing\n");
  601.         return;
  602.     }
  603.  
  604.     AcpiDmDisplayArguments (WalkState);
  605. }
  606.  
  607.  
  608. /*******************************************************************************
  609.  *
  610.  * FUNCTION:    AcpiDbDisplayResults
  611.  *
  612.  * PARAMETERS:  None
  613.  *
  614.  * RETURN:      None
  615.  *
  616.  * DESCRIPTION: Display current contents of a method result stack
  617.  *
  618.  ******************************************************************************/
  619.  
  620. void
  621. AcpiDbDisplayResults (
  622.     void)
  623. {
  624.     UINT32                  i;
  625.     ACPI_WALK_STATE         *WalkState;
  626.     ACPI_OPERAND_OBJECT     *ObjDesc;
  627.     UINT32                  ResultCount = 0;
  628.     ACPI_NAMESPACE_NODE     *Node;
  629.     ACPI_GENERIC_STATE      *Frame;
  630.     UINT32                  Index; /* Index onto current frame */
  631.  
  632.  
  633.     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
  634.     if (!WalkState)
  635.     {
  636.         AcpiOsPrintf ("There is no method currently executing\n");
  637.         return;
  638.     }
  639.  
  640.     ObjDesc = WalkState->MethodDesc;
  641.     Node    = WalkState->MethodNode;
  642.  
  643.     if (WalkState->Results)
  644.     {
  645.         ResultCount = WalkState->ResultCount;
  646.     }
  647.  
  648.     AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
  649.             AcpiUtGetNodeName (Node), ResultCount);
  650.  
  651.     /* From the top element of result stack */
  652.  
  653.     Frame = WalkState->Results;
  654.     Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
  655.  
  656.     for (i = 0; i < ResultCount; i++)
  657.     {
  658.         ObjDesc = Frame->Results.ObjDesc[Index];
  659.         AcpiOsPrintf ("Result%u: ", i);
  660.         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
  661.         if (Index == 0)
  662.         {
  663.             Frame = Frame->Results.Next;
  664.             Index = ACPI_RESULTS_FRAME_OBJ_NUM;
  665.         }
  666.         Index--;
  667.     }
  668. }
  669.  
  670.  
  671. /*******************************************************************************
  672.  *
  673.  * FUNCTION:    AcpiDbDisplayCallingTree
  674.  *
  675.  * PARAMETERS:  None
  676.  *
  677.  * RETURN:      None
  678.  *
  679.  * DESCRIPTION: Display current calling tree of nested control methods
  680.  *
  681.  ******************************************************************************/
  682.  
  683. void
  684. AcpiDbDisplayCallingTree (
  685.     void)
  686. {
  687.     ACPI_WALK_STATE         *WalkState;
  688.     ACPI_NAMESPACE_NODE     *Node;
  689.  
  690.  
  691.     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
  692.     if (!WalkState)
  693.     {
  694.         AcpiOsPrintf ("There is no method currently executing\n");
  695.         return;
  696.     }
  697.  
  698.     Node = WalkState->MethodNode;
  699.     AcpiOsPrintf ("Current Control Method Call Tree\n");
  700.  
  701.     while (WalkState)
  702.     {
  703.         Node = WalkState->MethodNode;
  704.  
  705.         AcpiOsPrintf ("    [%4.4s]\n", AcpiUtGetNodeName (Node));
  706.  
  707.         WalkState = WalkState->Next;
  708.     }
  709. }
  710.  
  711.  
  712. /*******************************************************************************
  713.  *
  714.  * FUNCTION:    AcpiDbDisplayObjectType
  715.  *
  716.  * PARAMETERS:  ObjectArg       - User entered NS node handle
  717.  *
  718.  * RETURN:      None
  719.  *
  720.  * DESCRIPTION: Display type of an arbitrary NS node
  721.  *
  722.  ******************************************************************************/
  723.  
  724. void
  725. AcpiDbDisplayObjectType (
  726.     char                    *ObjectArg)
  727. {
  728.     ACPI_HANDLE             Handle;
  729.     ACPI_DEVICE_INFO        *Info;
  730.     ACPI_STATUS             Status;
  731.     UINT32                  i;
  732.  
  733.  
  734.     Handle = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
  735.  
  736.     Status = AcpiGetObjectInfo (Handle, &Info);
  737.     if (ACPI_FAILURE (Status))
  738.     {
  739.         AcpiOsPrintf ("Could not get object info, %s\n",
  740.             AcpiFormatException (Status));
  741.         return;
  742.     }
  743.  
  744.     AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n",
  745.         ACPI_FORMAT_UINT64 (Info->Address),
  746.         Info->CurrentStatus, Info->Flags);
  747.  
  748.     AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
  749.         Info->HighestDstates[0], Info->HighestDstates[1],
  750.         Info->HighestDstates[2], Info->HighestDstates[3]);
  751.  
  752.     AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
  753.         Info->LowestDstates[0], Info->LowestDstates[1],
  754.         Info->LowestDstates[2], Info->LowestDstates[3],
  755.         Info->LowestDstates[4]);
  756.  
  757.     if (Info->Valid & ACPI_VALID_HID)
  758.     {
  759.         AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);
  760.     }
  761.     if (Info->Valid & ACPI_VALID_UID)
  762.     {
  763.         AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);
  764.     }
  765.     if (Info->Valid & ACPI_VALID_CID)
  766.     {
  767.         for (i = 0; i < Info->CompatibleIdList.Count; i++)
  768.         {
  769.             AcpiOsPrintf ("CID %u: %s\n", i,
  770.                 Info->CompatibleIdList.Ids[i].String);
  771.         }
  772.     }
  773.  
  774.     ACPI_FREE (Info);
  775. }
  776.  
  777.  
  778. /*******************************************************************************
  779.  *
  780.  * FUNCTION:    AcpiDbDisplayResultObject
  781.  *
  782.  * PARAMETERS:  ObjDesc         - Object to be displayed
  783.  *              WalkState       - Current walk state
  784.  *
  785.  * RETURN:      None
  786.  *
  787.  * DESCRIPTION: Display the result of an AML opcode
  788.  *
  789.  * Note: Curently only displays the result object if we are single stepping.
  790.  * However, this output may be useful in other contexts and could be enabled
  791.  * to do so if needed.
  792.  *
  793.  ******************************************************************************/
  794.  
  795. void
  796. AcpiDbDisplayResultObject (
  797.     ACPI_OPERAND_OBJECT     *ObjDesc,
  798.     ACPI_WALK_STATE         *WalkState)
  799. {
  800.  
  801.     /* Only display if single stepping */
  802.  
  803.     if (!AcpiGbl_CmSingleStep)
  804.     {
  805.         return;
  806.     }
  807.  
  808.     AcpiOsPrintf ("ResultObj: ");
  809.     AcpiDmDisplayInternalObject (ObjDesc, WalkState);
  810.     AcpiOsPrintf ("\n");
  811. }
  812.  
  813.  
  814. /*******************************************************************************
  815.  *
  816.  * FUNCTION:    AcpiDbDisplayArgumentObject
  817.  *
  818.  * PARAMETERS:  ObjDesc         - Object to be displayed
  819.  *              WalkState       - Current walk state
  820.  *
  821.  * RETURN:      None
  822.  *
  823.  * DESCRIPTION: Display the result of an AML opcode
  824.  *
  825.  ******************************************************************************/
  826.  
  827. void
  828. AcpiDbDisplayArgumentObject (
  829.     ACPI_OPERAND_OBJECT     *ObjDesc,
  830.     ACPI_WALK_STATE         *WalkState)
  831. {
  832.  
  833.     if (!AcpiGbl_CmSingleStep)
  834.     {
  835.         return;
  836.     }
  837.  
  838.     AcpiOsPrintf ("ArgObj:    ");
  839.     AcpiDmDisplayInternalObject (ObjDesc, WalkState);
  840. }
  841.  
  842.  
  843. /*******************************************************************************
  844.  *
  845.  * FUNCTION:    AcpiDbDisplayGpes
  846.  *
  847.  * PARAMETERS:  None
  848.  *
  849.  * RETURN:      None
  850.  *
  851.  * DESCRIPTION: Display the current GPE structures
  852.  *
  853.  ******************************************************************************/
  854.  
  855. void
  856. AcpiDbDisplayGpes (
  857.     void)
  858. {
  859.     ACPI_GPE_BLOCK_INFO     *GpeBlock;
  860.     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo;
  861.     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
  862.     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
  863.     char                    *GpeType;
  864.     UINT32                  GpeIndex;
  865.     UINT32                  Block = 0;
  866.     UINT32                  i;
  867.     UINT32                  j;
  868.     char                    Buffer[80];
  869.     ACPI_BUFFER             RetBuf;
  870.     ACPI_STATUS             Status;
  871.  
  872.  
  873.     RetBuf.Length = sizeof (Buffer);
  874.     RetBuf.Pointer = Buffer;
  875.  
  876.     Block = 0;
  877.  
  878.     /* Walk the GPE lists */
  879.  
  880.     GpeXruptInfo = AcpiGbl_GpeXruptListHead;
  881.     while (GpeXruptInfo)
  882.     {
  883.         GpeBlock = GpeXruptInfo->GpeBlockListHead;
  884.         while (GpeBlock)
  885.         {
  886.             Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf);
  887.             if (ACPI_FAILURE (Status))
  888.             {
  889.                 AcpiOsPrintf ("Could not convert name to pathname\n");
  890.             }
  891.  
  892.             if (GpeBlock->Node == AcpiGbl_FadtGpeDevice)
  893.             {
  894.                 GpeType = "FADT-defined GPE block";
  895.             }
  896.             else
  897.             {
  898.                 GpeType = "GPE Block Device";
  899.             }
  900.  
  901.             AcpiOsPrintf ("\nBlock %u - Info %p  DeviceNode %p [%s] - %s\n",
  902.                 Block, GpeBlock, GpeBlock->Node, Buffer, GpeType);
  903.  
  904.             AcpiOsPrintf ("    Registers:    %u (%u GPEs)\n",
  905.                 GpeBlock->RegisterCount, GpeBlock->GpeCount);
  906.  
  907.             AcpiOsPrintf ("    GPE range:    0x%X to 0x%X on interrupt %u\n",
  908.                 GpeBlock->BlockBaseNumber,
  909.                 GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1),
  910.                 GpeXruptInfo->InterruptNumber);
  911.  
  912.             AcpiOsPrintf (
  913.                 "    RegisterInfo: %p  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
  914.                 GpeBlock->RegisterInfo,
  915.                 ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address),
  916.                 ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address));
  917.  
  918.             AcpiOsPrintf ("    EventInfo:    %p\n", GpeBlock->EventInfo);
  919.  
  920.             /* Examine each GPE Register within the block */
  921.  
  922.             for (i = 0; i < GpeBlock->RegisterCount; i++)
  923.             {
  924.                 GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
  925.  
  926.                 AcpiOsPrintf (
  927.                     "    Reg %u: (GPE %.2X-%.2X)  RunEnable %2.2X WakeEnable %2.2X"
  928.                     " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
  929.                     i, GpeRegisterInfo->BaseGpeNumber,
  930.                     GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1),
  931.                     GpeRegisterInfo->EnableForRun,
  932.                     GpeRegisterInfo->EnableForWake,
  933.                     ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address),
  934.                     ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address));
  935.  
  936.                 /* Now look at the individual GPEs in this byte register */
  937.  
  938.                 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
  939.                 {
  940.                     GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
  941.                     GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
  942.  
  943.                     if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
  944.                         ACPI_GPE_DISPATCH_NONE)
  945.                     {
  946.                         /* This GPE is not used (no method or handler), ignore it */
  947.  
  948.                         continue;
  949.                     }
  950.  
  951.                     AcpiOsPrintf (
  952.                         "        GPE %.2X: %p  RunRefs %2.2X Flags %2.2X (",
  953.                         GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo,
  954.                         GpeEventInfo->RuntimeCount, GpeEventInfo->Flags);
  955.  
  956.                     /* Decode the flags byte */
  957.  
  958.                     if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
  959.                     {
  960.                         AcpiOsPrintf ("Level, ");
  961.                     }
  962.                     else
  963.                     {
  964.                         AcpiOsPrintf ("Edge,  ");
  965.                     }
  966.  
  967.                     if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)
  968.                     {
  969.                         AcpiOsPrintf ("CanWake, ");
  970.                     }
  971.                     else
  972.                     {
  973.                         AcpiOsPrintf ("RunOnly, ");
  974.                     }
  975.  
  976.                     switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
  977.                     {
  978.                     case ACPI_GPE_DISPATCH_NONE:
  979.                         AcpiOsPrintf ("NotUsed");
  980.                         break;
  981.                     case ACPI_GPE_DISPATCH_METHOD:
  982.                         AcpiOsPrintf ("Method");
  983.                         break;
  984.                     case ACPI_GPE_DISPATCH_HANDLER:
  985.                         AcpiOsPrintf ("Handler");
  986.                         break;
  987.                     case ACPI_GPE_DISPATCH_NOTIFY:
  988.                         AcpiOsPrintf ("Notify");
  989.                         break;
  990.                     default:
  991.                         AcpiOsPrintf ("UNKNOWN: %X",
  992.                             GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK);
  993.                         break;
  994.                     }
  995.  
  996.                     AcpiOsPrintf (")\n");
  997.                 }
  998.             }
  999.             Block++;
  1000.             GpeBlock = GpeBlock->Next;
  1001.         }
  1002.         GpeXruptInfo = GpeXruptInfo->Next;
  1003.     }
  1004. }
  1005.  
  1006.  
  1007. /*******************************************************************************
  1008.  *
  1009.  * FUNCTION:    AcpiDbDisplayHandlers
  1010.  *
  1011.  * PARAMETERS:  None
  1012.  *
  1013.  * RETURN:      None
  1014.  *
  1015.  * DESCRIPTION: Display the currently installed global handlers
  1016.  *
  1017.  ******************************************************************************/
  1018.  
  1019. void
  1020. AcpiDbDisplayHandlers (
  1021.     void)
  1022. {
  1023.     ACPI_OPERAND_OBJECT     *ObjDesc;
  1024.     ACPI_OPERAND_OBJECT     *HandlerObj;
  1025.     ACPI_ADR_SPACE_TYPE     SpaceId;
  1026.     UINT32                  i;
  1027.  
  1028.  
  1029.     /* Operation region handlers */
  1030.  
  1031.     AcpiOsPrintf ("\nOperation Region Handlers:\n");
  1032.  
  1033.     ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
  1034.     if (ObjDesc)
  1035.     {
  1036.         for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
  1037.         {
  1038.             SpaceId = AcpiGbl_SpaceIdList[i];
  1039.             HandlerObj = ObjDesc->Device.Handler;
  1040.  
  1041.             AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
  1042.                 AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
  1043.  
  1044.             while (HandlerObj)
  1045.             {
  1046.                 if (i == HandlerObj->AddressSpace.SpaceId)
  1047.                 {
  1048.                     AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
  1049.                         (HandlerObj->AddressSpace.HandlerFlags &
  1050.                             ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
  1051.                         HandlerObj->AddressSpace.Handler);
  1052.                     goto FoundHandler;
  1053.                 }
  1054.  
  1055.                 HandlerObj = HandlerObj->AddressSpace.Next;
  1056.             }
  1057.  
  1058.             /* There is no handler for this SpaceId */
  1059.  
  1060.             AcpiOsPrintf ("None\n");
  1061.  
  1062.         FoundHandler:;
  1063.         }
  1064.     }
  1065.  
  1066.     /* Fixed event handlers */
  1067.  
  1068.     AcpiOsPrintf ("\nFixed Event Handlers:\n");
  1069.  
  1070.     for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
  1071.     {
  1072.         AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);
  1073.         if (AcpiGbl_FixedEventHandlers[i].Handler)
  1074.         {
  1075.             AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
  1076.                 AcpiGbl_FixedEventHandlers[i].Handler);
  1077.         }
  1078.         else
  1079.         {
  1080.             AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
  1081.         }
  1082.     }
  1083.  
  1084.     /* Miscellaneous global handlers */
  1085.  
  1086.     AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");
  1087.  
  1088.     for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++)
  1089.     {
  1090.         AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, AcpiGbl_HandlerList[i].Name);
  1091.         if (AcpiGbl_HandlerList[i].Handler)
  1092.         {
  1093.             AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
  1094.                 AcpiGbl_HandlerList[i].Handler);
  1095.         }
  1096.         else
  1097.         {
  1098.             AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
  1099.         }
  1100.     }
  1101. }
  1102.  
  1103. #endif /* ACPI_DEBUGGER */
  1104.