xref: /onnv-gate/usr/src/uts/intel/io/acpica/debugger/dbcmds.c (revision 11225:eb6056029d84)
13446Smrj /*******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: dbcmds - debug commands and output routines
43446Smrj  *
53446Smrj  ******************************************************************************/
63446Smrj 
73446Smrj /******************************************************************************
83446Smrj  *
93446Smrj  * 1. Copyright Notice
103446Smrj  *
119980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj  * All rights reserved.
133446Smrj  *
143446Smrj  * 2. License
153446Smrj  *
163446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj  * rights.  You may have additional license terms from the party that provided
183446Smrj  * you this software, covering your right to use that party's intellectual
193446Smrj  * property rights.
203446Smrj  *
213446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj  * copy of the source code appearing in this file ("Covered Code") an
233446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj  * make derivatives, distribute, use and display any portion of the Covered
263446Smrj  * Code in any form, with the right to sublicense such rights; and
273446Smrj  *
283446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj  * license (with the right to sublicense), under only those claims of Intel
303446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj  * solely to the minimum extent necessary to exercise the above copyright
333446Smrj  * license, and in no event shall the patent license extend to any additions
343446Smrj  * to or modifications of the Original Intel Code.  No other license or right
353446Smrj  * is granted directly or by implication, estoppel or otherwise;
363446Smrj  *
373446Smrj  * The above copyright and patent license is granted only if the following
383446Smrj  * conditions are met:
393446Smrj  *
403446Smrj  * 3. Conditions
413446Smrj  *
423446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj  * Redistribution of source code of any substantial portion of the Covered
443446Smrj  * Code or modification with rights to further distribute source must include
453446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
473446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj  * contain a file documenting the changes Licensee made to create that Covered
493446Smrj  * Code and the date of any change.  Licensee must include in that file the
503446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
513446Smrj  * must include a prominent statement that the modification is derived,
523446Smrj  * directly or indirectly, from Original Intel Code.
533446Smrj  *
543446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj  * Redistribution of source code of any substantial portion of the Covered
563446Smrj  * Code or modification without rights to further distribute source must
573446Smrj  * include the following Disclaimer and Export Compliance provision in the
583446Smrj  * documentation and/or other materials provided with distribution.  In
593446Smrj  * addition, Licensee may not authorize further sublicense of source of any
603446Smrj  * portion of the Covered Code, and must include terms to the effect that the
613446Smrj  * license from Licensee to its licensee is limited to the intellectual
623446Smrj  * property embodied in the software Licensee provides to its licensee, and
633446Smrj  * not to intellectual property embodied in modifications its licensee may
643446Smrj  * make.
653446Smrj  *
663446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj  * substantial portion of the Covered Code or modification must reproduce the
683446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj  * provision in the documentation and/or other materials provided with the
703446Smrj  * distribution.
713446Smrj  *
723446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj  * Intel Code.
743446Smrj  *
753446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj  * other dealings in products derived from or relating to the Covered Code
783446Smrj  * without prior written authorization from Intel.
793446Smrj  *
803446Smrj  * 4. Disclaimer and Export Compliance
813446Smrj  *
823446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
853446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
863446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj  * PARTICULAR PURPOSE.
893446Smrj  *
903446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
963446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj  * LIMITED REMEDY.
983446Smrj  *
993446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj  * software or system incorporating such software without first obtaining any
1013446Smrj  * required license or other approval from the U. S. Department of Commerce or
1023446Smrj  * any other agency or department of the United States Government.  In the
1033446Smrj  * event Licensee exports any such software from the United States or
1043446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj  * ensure that the distribution and export/re-export of the software is in
1063446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj  * software, or service, directly or indirectly, to any country for which the
1103446Smrj  * United States government or any agency thereof requires an export license,
1113446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj  * such license, approval or letter.
1133446Smrj  *
1143446Smrj  *****************************************************************************/
1153446Smrj 
1163446Smrj 
1173446Smrj #include "acpi.h"
1189980SDana.Myers@Sun.COM #include "accommon.h"
1193446Smrj #include "acdispat.h"
1203446Smrj #include "acnamesp.h"
1213446Smrj #include "acevents.h"
1223446Smrj #include "acdebug.h"
1233446Smrj #include "acresrc.h"
1243446Smrj #include "acdisasm.h"
1257851SDana.Myers@Sun.COM #include "actables.h"
1263446Smrj #include "acparser.h"
1273446Smrj 
1283446Smrj #ifdef ACPI_DEBUGGER
1293446Smrj 
1303446Smrj #define _COMPONENT          ACPI_CA_DEBUGGER
1313446Smrj         ACPI_MODULE_NAME    ("dbcmds")
1323446Smrj 
133*11225SDana.Myers@Sun.COM 
1343446Smrj /* Local prototypes */
1353446Smrj 
1363446Smrj static ACPI_STATUS
1373446Smrj AcpiDbIntegrityWalk (
1383446Smrj     ACPI_HANDLE             ObjHandle,
1393446Smrj     UINT32                  NestingLevel,
1403446Smrj     void                    *Context,
1413446Smrj     void                    **ReturnValue);
1423446Smrj 
1433446Smrj static ACPI_STATUS
1443446Smrj AcpiDbWalkAndMatchName (
1453446Smrj     ACPI_HANDLE             ObjHandle,
1463446Smrj     UINT32                  NestingLevel,
1473446Smrj     void                    *Context,
1483446Smrj     void                    **ReturnValue);
1493446Smrj 
1503446Smrj static ACPI_STATUS
1513446Smrj AcpiDbWalkForReferences (
1523446Smrj     ACPI_HANDLE             ObjHandle,
1533446Smrj     UINT32                  NestingLevel,
1543446Smrj     void                    *Context,
1553446Smrj     void                    **ReturnValue);
1563446Smrj 
1573446Smrj static ACPI_STATUS
1583446Smrj AcpiDbWalkForSpecificObjects (
1593446Smrj     ACPI_HANDLE             ObjHandle,
1603446Smrj     UINT32                  NestingLevel,
1613446Smrj     void                    *Context,
1623446Smrj     void                    **ReturnValue);
1633446Smrj 
1643446Smrj static ACPI_NAMESPACE_NODE *
1653446Smrj AcpiDbConvertToNode (
1663446Smrj     char                    *InString);
1673446Smrj 
1683446Smrj static void
1693446Smrj AcpiDmCompareAmlResources (
1703446Smrj     UINT8                   *Aml1Buffer,
1713446Smrj     ACPI_RSDESC_SIZE        Aml1BufferLength,
1723446Smrj     UINT8                   *Aml2Buffer,
1733446Smrj     ACPI_RSDESC_SIZE        Aml2BufferLength);
1743446Smrj 
1753446Smrj static ACPI_STATUS
1763446Smrj AcpiDmTestResourceConversion (
1773446Smrj     ACPI_NAMESPACE_NODE     *Node,
1783446Smrj     char                    *Name);
1793446Smrj 
1803446Smrj 
1813446Smrj /*
1823446Smrj  * Arguments for the Objects command
1833446Smrj  * These object types map directly to the ACPI_TYPES
1843446Smrj  */
1853446Smrj static ARGUMENT_INFO        AcpiDbObjectTypes [] =
1863446Smrj {
1873446Smrj     {"ANY"},
1883446Smrj     {"INTEGERS"},
1893446Smrj     {"STRINGS"},
1903446Smrj     {"BUFFERS"},
1913446Smrj     {"PACKAGES"},
1923446Smrj     {"FIELDS"},
1933446Smrj     {"DEVICES"},
1943446Smrj     {"EVENTS"},
1953446Smrj     {"METHODS"},
1963446Smrj     {"MUTEXES"},
1973446Smrj     {"REGIONS"},
1983446Smrj     {"POWERRESOURCES"},
1993446Smrj     {"PROCESSORS"},
2003446Smrj     {"THERMALZONES"},
2013446Smrj     {"BUFFERFIELDS"},
2023446Smrj     {"DDBHANDLES"},
2033446Smrj     {"DEBUG"},
2043446Smrj     {"REGIONFIELDS"},
2053446Smrj     {"BANKFIELDS"},
2063446Smrj     {"INDEXFIELDS"},
2073446Smrj     {"REFERENCES"},
2083446Smrj     {"ALIAS"},
2093446Smrj     {NULL}           /* Must be null terminated */
2103446Smrj };
2113446Smrj 
2123446Smrj 
2133446Smrj /*******************************************************************************
2143446Smrj  *
2153446Smrj  * FUNCTION:    AcpiDbConvertToNode
2163446Smrj  *
2173446Smrj  * PARAMETERS:  InString        - String to convert
2183446Smrj  *
2193446Smrj  * RETURN:      Pointer to a NS node
2203446Smrj  *
2213446Smrj  * DESCRIPTION: Convert a string to a valid NS pointer.  Handles numeric or
2223446Smrj  *              alpha strings.
2233446Smrj  *
2243446Smrj  ******************************************************************************/
2253446Smrj 
2263446Smrj static ACPI_NAMESPACE_NODE *
AcpiDbConvertToNode(char * InString)2273446Smrj AcpiDbConvertToNode (
2283446Smrj     char                    *InString)
2293446Smrj {
2303446Smrj     ACPI_NAMESPACE_NODE     *Node;
2313446Smrj 
2323446Smrj 
2333446Smrj     if ((*InString >= 0x30) && (*InString <= 0x39))
2343446Smrj     {
2353446Smrj         /* Numeric argument, convert */
2363446Smrj 
2373446Smrj         Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16));
2383446Smrj         if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
2393446Smrj         {
2403446Smrj             AcpiOsPrintf ("Address %p is invalid in this address space\n",
2413446Smrj                 Node);
2423446Smrj             return (NULL);
2433446Smrj         }
2443446Smrj 
2453446Smrj         /* Make sure pointer is valid NS node */
2463446Smrj 
2473446Smrj         if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
2483446Smrj         {
2493446Smrj             AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
2503446Smrj                     Node, AcpiUtGetDescriptorName (Node));
2513446Smrj             return (NULL);
2523446Smrj         }
2533446Smrj     }
2543446Smrj     else
2553446Smrj     {
2563446Smrj         /* Alpha argument */
2573446Smrj         /* The parameter is a name string that must be resolved to a
2583446Smrj          * Named obj
2593446Smrj          */
2603446Smrj         Node = AcpiDbLocalNsLookup (InString);
2613446Smrj         if (!Node)
2623446Smrj         {
2633446Smrj             Node = AcpiGbl_RootNode;
2643446Smrj         }
2653446Smrj     }
2663446Smrj 
2673446Smrj     return (Node);
2683446Smrj }
2693446Smrj 
2703446Smrj 
2713446Smrj /*******************************************************************************
2723446Smrj  *
2733446Smrj  * FUNCTION:    AcpiDbSleep
2743446Smrj  *
2753446Smrj  * PARAMETERS:  ObjectArg       - Desired sleep state (0-5)
2763446Smrj  *
2773446Smrj  * RETURN:      Status
2783446Smrj  *
2793446Smrj  * DESCRIPTION: Simulate a sleep/wake sequence
2803446Smrj  *
2813446Smrj  ******************************************************************************/
2823446Smrj 
2833446Smrj ACPI_STATUS
AcpiDbSleep(char * ObjectArg)2843446Smrj AcpiDbSleep (
2853446Smrj     char                    *ObjectArg)
2863446Smrj {
2873446Smrj     ACPI_STATUS             Status;
2883446Smrj     UINT8                   SleepState;
2893446Smrj 
2903446Smrj 
2913446Smrj     SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
2923446Smrj 
2933446Smrj     AcpiOsPrintf ("**** Prepare to sleep ****\n");
2943446Smrj     Status = AcpiEnterSleepStatePrep (SleepState);
2953446Smrj     if (ACPI_FAILURE (Status))
2963446Smrj     {
2973446Smrj         return (Status);
2983446Smrj     }
2993446Smrj 
3003446Smrj     AcpiOsPrintf ("**** Going to sleep ****\n");
3013446Smrj     Status = AcpiEnterSleepState (SleepState);
3023446Smrj     if (ACPI_FAILURE (Status))
3033446Smrj     {
3043446Smrj         return (Status);
3053446Smrj     }
3063446Smrj 
3073446Smrj     AcpiOsPrintf ("**** returning from sleep ****\n");
3083446Smrj     Status = AcpiLeaveSleepState (SleepState);
3093446Smrj 
3103446Smrj     return (Status);
3113446Smrj }
3123446Smrj 
3133446Smrj 
3143446Smrj /*******************************************************************************
3153446Smrj  *
3163446Smrj  * FUNCTION:    AcpiDbWalkForReferences
3173446Smrj  *
3183446Smrj  * PARAMETERS:  Callback from WalkNamespace
3193446Smrj  *
3203446Smrj  * RETURN:      Status
3213446Smrj  *
3223446Smrj  * DESCRIPTION: Check if this namespace object refers to the target object
3233446Smrj  *              that is passed in as the context value.
3243446Smrj  *
3253446Smrj  * Note: Currently doesn't check subobjects within the Node's object
3263446Smrj  *
3273446Smrj  ******************************************************************************/
3283446Smrj 
3293446Smrj static ACPI_STATUS
AcpiDbWalkForReferences(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)3303446Smrj AcpiDbWalkForReferences (
3313446Smrj     ACPI_HANDLE             ObjHandle,
3323446Smrj     UINT32                  NestingLevel,
3333446Smrj     void                    *Context,
3343446Smrj     void                    **ReturnValue)
3353446Smrj {
3363446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc = (ACPI_OPERAND_OBJECT  *) Context;
3373446Smrj     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
3383446Smrj 
3393446Smrj 
3403446Smrj     /* Check for match against the namespace node itself */
3413446Smrj 
3423446Smrj     if (Node == (void *) ObjDesc)
3433446Smrj     {
3443446Smrj         AcpiOsPrintf ("Object is a Node [%4.4s]\n",
3453446Smrj             AcpiUtGetNodeName (Node));
3463446Smrj     }
3473446Smrj 
3483446Smrj     /* Check for match against the object attached to the node */
3493446Smrj 
3503446Smrj     if (AcpiNsGetAttachedObject (Node) == ObjDesc)
3513446Smrj     {
3523446Smrj         AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
3533446Smrj             Node, AcpiUtGetNodeName (Node));
3543446Smrj     }
3553446Smrj 
3563446Smrj     return (AE_OK);
3573446Smrj }
3583446Smrj 
3593446Smrj 
3603446Smrj /*******************************************************************************
3613446Smrj  *
3623446Smrj  * FUNCTION:    AcpiDbFindReferences
3633446Smrj  *
3643446Smrj  * PARAMETERS:  ObjectArg       - String with hex value of the object
3653446Smrj  *
3663446Smrj  * RETURN:      None
3673446Smrj  *
3683446Smrj  * DESCRIPTION: Search namespace for all references to the input object
3693446Smrj  *
3703446Smrj  ******************************************************************************/
3713446Smrj 
3723446Smrj void
AcpiDbFindReferences(char * ObjectArg)3733446Smrj AcpiDbFindReferences (
3743446Smrj     char                    *ObjectArg)
3753446Smrj {
3763446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
3773446Smrj 
3783446Smrj 
3793446Smrj     /* Convert string to object pointer */
3803446Smrj 
3813446Smrj     ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
3823446Smrj 
3833446Smrj     /* Search all nodes in namespace */
3843446Smrj 
3853446Smrj     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
386*11225SDana.Myers@Sun.COM                     AcpiDbWalkForReferences, NULL, (void *) ObjDesc, NULL);
3873446Smrj }
3883446Smrj 
3893446Smrj 
3903446Smrj /*******************************************************************************
3913446Smrj  *
3929980SDana.Myers@Sun.COM  * FUNCTION:    AcpiDbWalkForPredefinedNames
3939980SDana.Myers@Sun.COM  *
3949980SDana.Myers@Sun.COM  * PARAMETERS:  Callback from WalkNamespace
3959980SDana.Myers@Sun.COM  *
3969980SDana.Myers@Sun.COM  * RETURN:      Status
3979980SDana.Myers@Sun.COM  *
3989980SDana.Myers@Sun.COM  * DESCRIPTION: Detect and display predefined ACPI names (names that start with
3999980SDana.Myers@Sun.COM  *              an underscore)
4009980SDana.Myers@Sun.COM  *
4019980SDana.Myers@Sun.COM  ******************************************************************************/
4029980SDana.Myers@Sun.COM 
4039980SDana.Myers@Sun.COM static ACPI_STATUS
AcpiDbWalkForPredefinedNames(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)4049980SDana.Myers@Sun.COM AcpiDbWalkForPredefinedNames (
4059980SDana.Myers@Sun.COM     ACPI_HANDLE             ObjHandle,
4069980SDana.Myers@Sun.COM     UINT32                  NestingLevel,
4079980SDana.Myers@Sun.COM     void                    *Context,
4089980SDana.Myers@Sun.COM     void                    **ReturnValue)
4099980SDana.Myers@Sun.COM {
4109980SDana.Myers@Sun.COM     ACPI_NAMESPACE_NODE         *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
4119980SDana.Myers@Sun.COM     UINT32                      *Count = (UINT32 *) Context;
4129980SDana.Myers@Sun.COM     const ACPI_PREDEFINED_INFO  *Predefined;
4139980SDana.Myers@Sun.COM     const ACPI_PREDEFINED_INFO  *Package = NULL;
4149980SDana.Myers@Sun.COM     char                        *Pathname;
4159980SDana.Myers@Sun.COM 
4169980SDana.Myers@Sun.COM 
4179980SDana.Myers@Sun.COM     Predefined = AcpiNsCheckForPredefinedName (Node);
4189980SDana.Myers@Sun.COM     if (!Predefined)
4199980SDana.Myers@Sun.COM     {
4209980SDana.Myers@Sun.COM         return (AE_OK);
4219980SDana.Myers@Sun.COM     }
4229980SDana.Myers@Sun.COM 
4239980SDana.Myers@Sun.COM     Pathname = AcpiNsGetExternalPathname (Node);
4249980SDana.Myers@Sun.COM     if (!Pathname)
4259980SDana.Myers@Sun.COM     {
4269980SDana.Myers@Sun.COM         return (AE_OK);
4279980SDana.Myers@Sun.COM     }
4289980SDana.Myers@Sun.COM 
4299980SDana.Myers@Sun.COM     /* If method returns a package, the info is in the next table entry */
4309980SDana.Myers@Sun.COM 
4319980SDana.Myers@Sun.COM     if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE)
4329980SDana.Myers@Sun.COM     {
4339980SDana.Myers@Sun.COM         Package = Predefined + 1;
4349980SDana.Myers@Sun.COM     }
4359980SDana.Myers@Sun.COM 
4369980SDana.Myers@Sun.COM     AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname,
4379980SDana.Myers@Sun.COM         Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes);
4389980SDana.Myers@Sun.COM 
4399980SDana.Myers@Sun.COM     if (Package)
4409980SDana.Myers@Sun.COM     {
4419980SDana.Myers@Sun.COM         AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X",
4429980SDana.Myers@Sun.COM             Package->RetInfo.Type, Package->RetInfo.ObjectType1,
4439980SDana.Myers@Sun.COM             Package->RetInfo.Count1);
4449980SDana.Myers@Sun.COM     }
4459980SDana.Myers@Sun.COM 
4469980SDana.Myers@Sun.COM     AcpiOsPrintf("\n");
4479980SDana.Myers@Sun.COM 
4489980SDana.Myers@Sun.COM     AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined);
4499980SDana.Myers@Sun.COM     ACPI_FREE (Pathname);
4509980SDana.Myers@Sun.COM     (*Count)++;
4519980SDana.Myers@Sun.COM 
4529980SDana.Myers@Sun.COM     return (AE_OK);
4539980SDana.Myers@Sun.COM }
4549980SDana.Myers@Sun.COM 
4559980SDana.Myers@Sun.COM 
4569980SDana.Myers@Sun.COM /*******************************************************************************
4579980SDana.Myers@Sun.COM  *
4589980SDana.Myers@Sun.COM  * FUNCTION:    AcpiDbCheckPredefinedNames
4599980SDana.Myers@Sun.COM  *
4609980SDana.Myers@Sun.COM  * PARAMETERS:  None
4619980SDana.Myers@Sun.COM  *
4629980SDana.Myers@Sun.COM  * RETURN:      None
4639980SDana.Myers@Sun.COM  *
4649980SDana.Myers@Sun.COM  * DESCRIPTION: Validate all predefined names in the namespace
4659980SDana.Myers@Sun.COM  *
4669980SDana.Myers@Sun.COM  ******************************************************************************/
4679980SDana.Myers@Sun.COM 
4689980SDana.Myers@Sun.COM void
AcpiDbCheckPredefinedNames(void)4699980SDana.Myers@Sun.COM AcpiDbCheckPredefinedNames (
4709980SDana.Myers@Sun.COM     void)
4719980SDana.Myers@Sun.COM {
4729980SDana.Myers@Sun.COM     UINT32                  Count = 0;
4739980SDana.Myers@Sun.COM 
4749980SDana.Myers@Sun.COM 
4759980SDana.Myers@Sun.COM     /* Search all nodes in namespace */
4769980SDana.Myers@Sun.COM 
4779980SDana.Myers@Sun.COM     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
478*11225SDana.Myers@Sun.COM                 AcpiDbWalkForPredefinedNames, NULL, (void *) &Count, NULL);
4799980SDana.Myers@Sun.COM 
4809980SDana.Myers@Sun.COM     AcpiOsPrintf ("Found %d predefined names in the namespace\n", Count);
4819980SDana.Myers@Sun.COM }
4829980SDana.Myers@Sun.COM 
4839980SDana.Myers@Sun.COM 
4849980SDana.Myers@Sun.COM /*******************************************************************************
4859980SDana.Myers@Sun.COM  *
4869980SDana.Myers@Sun.COM  * FUNCTION:    AcpiDbWalkForExecute
4879980SDana.Myers@Sun.COM  *
4889980SDana.Myers@Sun.COM  * PARAMETERS:  Callback from WalkNamespace
4899980SDana.Myers@Sun.COM  *
4909980SDana.Myers@Sun.COM  * RETURN:      Status
4919980SDana.Myers@Sun.COM  *
4929980SDana.Myers@Sun.COM  * DESCRIPTION: Batch execution module. Currently only executes predefined
4939980SDana.Myers@Sun.COM  *              ACPI names.
4949980SDana.Myers@Sun.COM  *
4959980SDana.Myers@Sun.COM  ******************************************************************************/
4969980SDana.Myers@Sun.COM 
4979980SDana.Myers@Sun.COM static ACPI_STATUS
AcpiDbWalkForExecute(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)4989980SDana.Myers@Sun.COM AcpiDbWalkForExecute (
4999980SDana.Myers@Sun.COM     ACPI_HANDLE             ObjHandle,
5009980SDana.Myers@Sun.COM     UINT32                  NestingLevel,
5019980SDana.Myers@Sun.COM     void                    *Context,
5029980SDana.Myers@Sun.COM     void                    **ReturnValue)
5039980SDana.Myers@Sun.COM {
504*11225SDana.Myers@Sun.COM     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
505*11225SDana.Myers@Sun.COM     ACPI_EXECUTE_WALK       *Info = (ACPI_EXECUTE_WALK *) Context;
506*11225SDana.Myers@Sun.COM     ACPI_BUFFER             ReturnObj;
507*11225SDana.Myers@Sun.COM     ACPI_STATUS             Status;
508*11225SDana.Myers@Sun.COM     char                    *Pathname;
5099980SDana.Myers@Sun.COM     UINT32                  i;
5109980SDana.Myers@Sun.COM     ACPI_DEVICE_INFO        *ObjInfo;
5119980SDana.Myers@Sun.COM     ACPI_OBJECT_LIST        ParamObjects;
5129980SDana.Myers@Sun.COM     ACPI_OBJECT             Params[ACPI_METHOD_NUM_ARGS];
513*11225SDana.Myers@Sun.COM     const ACPI_PREDEFINED_INFO *Predefined;
5149980SDana.Myers@Sun.COM 
5159980SDana.Myers@Sun.COM 
5169980SDana.Myers@Sun.COM     Predefined = AcpiNsCheckForPredefinedName (Node);
5179980SDana.Myers@Sun.COM     if (!Predefined)
5189980SDana.Myers@Sun.COM     {
5199980SDana.Myers@Sun.COM         return (AE_OK);
5209980SDana.Myers@Sun.COM     }
5219980SDana.Myers@Sun.COM 
5229980SDana.Myers@Sun.COM     if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
5239980SDana.Myers@Sun.COM     {
5249980SDana.Myers@Sun.COM         return (AE_OK);
5259980SDana.Myers@Sun.COM     }
5269980SDana.Myers@Sun.COM 
5279980SDana.Myers@Sun.COM     Pathname = AcpiNsGetExternalPathname (Node);
5289980SDana.Myers@Sun.COM     if (!Pathname)
5299980SDana.Myers@Sun.COM     {
5309980SDana.Myers@Sun.COM         return (AE_OK);
5319980SDana.Myers@Sun.COM     }
5329980SDana.Myers@Sun.COM 
5339980SDana.Myers@Sun.COM     /* Get the object info for number of method parameters */
5349980SDana.Myers@Sun.COM 
535*11225SDana.Myers@Sun.COM     Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
5369980SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
5379980SDana.Myers@Sun.COM     {
5389980SDana.Myers@Sun.COM         return (Status);
5399980SDana.Myers@Sun.COM     }
5409980SDana.Myers@Sun.COM 
5419980SDana.Myers@Sun.COM     ParamObjects.Pointer = NULL;
5429980SDana.Myers@Sun.COM     ParamObjects.Count   = 0;
5439980SDana.Myers@Sun.COM 
5449980SDana.Myers@Sun.COM     if (ObjInfo->Type == ACPI_TYPE_METHOD)
5459980SDana.Myers@Sun.COM     {
5469980SDana.Myers@Sun.COM         /* Setup default parameters */
5479980SDana.Myers@Sun.COM 
5489980SDana.Myers@Sun.COM         for (i = 0; i < ObjInfo->ParamCount; i++)
5499980SDana.Myers@Sun.COM         {
5509980SDana.Myers@Sun.COM             Params[i].Type           = ACPI_TYPE_INTEGER;
5519980SDana.Myers@Sun.COM             Params[i].Integer.Value  = 1;
5529980SDana.Myers@Sun.COM         }
5539980SDana.Myers@Sun.COM 
5549980SDana.Myers@Sun.COM         ParamObjects.Pointer     = Params;
5559980SDana.Myers@Sun.COM         ParamObjects.Count       = ObjInfo->ParamCount;
5569980SDana.Myers@Sun.COM     }
5579980SDana.Myers@Sun.COM 
558*11225SDana.Myers@Sun.COM     ACPI_FREE (ObjInfo);
5599980SDana.Myers@Sun.COM     ReturnObj.Pointer = NULL;
5609980SDana.Myers@Sun.COM     ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
5619980SDana.Myers@Sun.COM 
5629980SDana.Myers@Sun.COM     /* Do the actual method execution */
5639980SDana.Myers@Sun.COM 
5649980SDana.Myers@Sun.COM     AcpiGbl_MethodExecuting = TRUE;
5659980SDana.Myers@Sun.COM 
5669980SDana.Myers@Sun.COM     Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
5679980SDana.Myers@Sun.COM 
5689980SDana.Myers@Sun.COM     AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
5699980SDana.Myers@Sun.COM     AcpiGbl_MethodExecuting = FALSE;
570*11225SDana.Myers@Sun.COM     ACPI_FREE (Pathname);
5719980SDana.Myers@Sun.COM 
572*11225SDana.Myers@Sun.COM     /* Ignore status from method execution */
573*11225SDana.Myers@Sun.COM 
574*11225SDana.Myers@Sun.COM     Status = AE_OK;
575*11225SDana.Myers@Sun.COM 
576*11225SDana.Myers@Sun.COM     /* Update count, check if we have executed enough methods */
5779980SDana.Myers@Sun.COM 
578*11225SDana.Myers@Sun.COM     Info->Count++;
579*11225SDana.Myers@Sun.COM     if (Info->Count >= Info->MaxCount)
580*11225SDana.Myers@Sun.COM     {
581*11225SDana.Myers@Sun.COM         Status = AE_CTRL_TERMINATE;
582*11225SDana.Myers@Sun.COM     }
583*11225SDana.Myers@Sun.COM 
584*11225SDana.Myers@Sun.COM     return (Status);
5859980SDana.Myers@Sun.COM }
5869980SDana.Myers@Sun.COM 
5879980SDana.Myers@Sun.COM 
5889980SDana.Myers@Sun.COM /*******************************************************************************
5899980SDana.Myers@Sun.COM  *
5909980SDana.Myers@Sun.COM  * FUNCTION:    AcpiDbBatchExecute
5919980SDana.Myers@Sun.COM  *
592*11225SDana.Myers@Sun.COM  * PARAMETERS:  CountArg            - Max number of methods to execute
5939980SDana.Myers@Sun.COM  *
5949980SDana.Myers@Sun.COM  * RETURN:      None
5959980SDana.Myers@Sun.COM  *
596*11225SDana.Myers@Sun.COM  * DESCRIPTION: Namespace batch execution. Execute predefined names in the
597*11225SDana.Myers@Sun.COM  *              namespace, up to the max count, if specified.
5989980SDana.Myers@Sun.COM  *
5999980SDana.Myers@Sun.COM  ******************************************************************************/
6009980SDana.Myers@Sun.COM 
6019980SDana.Myers@Sun.COM void
AcpiDbBatchExecute(char * CountArg)6029980SDana.Myers@Sun.COM AcpiDbBatchExecute (
603*11225SDana.Myers@Sun.COM     char                    *CountArg)
6049980SDana.Myers@Sun.COM {
605*11225SDana.Myers@Sun.COM     ACPI_EXECUTE_WALK       Info;
606*11225SDana.Myers@Sun.COM 
607*11225SDana.Myers@Sun.COM 
608*11225SDana.Myers@Sun.COM     Info.Count = 0;
609*11225SDana.Myers@Sun.COM     Info.MaxCount = ACPI_UINT32_MAX;
610*11225SDana.Myers@Sun.COM 
611*11225SDana.Myers@Sun.COM     if (CountArg)
612*11225SDana.Myers@Sun.COM     {
613*11225SDana.Myers@Sun.COM         Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0);
614*11225SDana.Myers@Sun.COM     }
6159980SDana.Myers@Sun.COM 
6169980SDana.Myers@Sun.COM 
6179980SDana.Myers@Sun.COM     /* Search all nodes in namespace */
6189980SDana.Myers@Sun.COM 
6199980SDana.Myers@Sun.COM     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
620*11225SDana.Myers@Sun.COM                 AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
6219980SDana.Myers@Sun.COM 
622*11225SDana.Myers@Sun.COM     AcpiOsPrintf ("Executed %d predefined names in the namespace\n", Info.Count);
6239980SDana.Myers@Sun.COM }
6249980SDana.Myers@Sun.COM 
6259980SDana.Myers@Sun.COM 
6269980SDana.Myers@Sun.COM /*******************************************************************************
6279980SDana.Myers@Sun.COM  *
6283446Smrj  * FUNCTION:    AcpiDbDisplayLocks
6293446Smrj  *
6303446Smrj  * PARAMETERS:  None
6313446Smrj  *
6323446Smrj  * RETURN:      None
6333446Smrj  *
6343446Smrj  * DESCRIPTION: Display information about internal mutexes.
6353446Smrj  *
6363446Smrj  ******************************************************************************/
6373446Smrj 
6383446Smrj void
AcpiDbDisplayLocks(void)6393446Smrj AcpiDbDisplayLocks (
6403446Smrj     void)
6413446Smrj {
6423446Smrj     UINT32                  i;
6433446Smrj 
6443446Smrj 
6453446Smrj     for (i = 0; i < ACPI_MAX_MUTEX; i++)
6463446Smrj     {
6473446Smrj         AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
6483446Smrj             AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
6493446Smrj                 ? "Locked" : "Unlocked");
6503446Smrj     }
6513446Smrj }
6523446Smrj 
6533446Smrj 
6543446Smrj /*******************************************************************************
6553446Smrj  *
6563446Smrj  * FUNCTION:    AcpiDbDisplayTableInfo
6573446Smrj  *
6583446Smrj  * PARAMETERS:  TableArg        - String with name of table to be displayed
6593446Smrj  *
6603446Smrj  * RETURN:      None
6613446Smrj  *
6623446Smrj  * DESCRIPTION: Display information about loaded tables.  Current
6633446Smrj  *              implementation displays all loaded tables.
6643446Smrj  *
6653446Smrj  ******************************************************************************/
6663446Smrj 
6673446Smrj void
AcpiDbDisplayTableInfo(char * TableArg)6683446Smrj AcpiDbDisplayTableInfo (
6693446Smrj     char                    *TableArg)
6703446Smrj {
6713446Smrj     UINT32                  i;
6723446Smrj     ACPI_TABLE_DESC         *TableDesc;
6739980SDana.Myers@Sun.COM     ACPI_STATUS             Status;
6743446Smrj 
6753446Smrj 
6767851SDana.Myers@Sun.COM     /* Walk the entire root table list */
6777851SDana.Myers@Sun.COM 
6787851SDana.Myers@Sun.COM     for (i = 0; i < AcpiGbl_RootTableList.Count; i++)
6793446Smrj     {
6807851SDana.Myers@Sun.COM         TableDesc = &AcpiGbl_RootTableList.Tables[i];
6817851SDana.Myers@Sun.COM         AcpiOsPrintf ("%d ", i);
6827851SDana.Myers@Sun.COM 
6837851SDana.Myers@Sun.COM         /* Make sure that the table is mapped */
6847851SDana.Myers@Sun.COM 
6859980SDana.Myers@Sun.COM         Status = AcpiTbVerifyTable (TableDesc);
6869980SDana.Myers@Sun.COM         if (ACPI_FAILURE (Status))
6879980SDana.Myers@Sun.COM         {
6889980SDana.Myers@Sun.COM             return;
6899980SDana.Myers@Sun.COM         }
6903446Smrj 
6917851SDana.Myers@Sun.COM         /* Dump the table header */
6923446Smrj 
6937851SDana.Myers@Sun.COM         if (TableDesc->Pointer)
6947851SDana.Myers@Sun.COM         {
6957851SDana.Myers@Sun.COM             AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
6967851SDana.Myers@Sun.COM         }
6977851SDana.Myers@Sun.COM         else
6987851SDana.Myers@Sun.COM         {
6997851SDana.Myers@Sun.COM             /* If the pointer is null, the table has been unloaded */
7007851SDana.Myers@Sun.COM 
7017851SDana.Myers@Sun.COM             ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
7027851SDana.Myers@Sun.COM                 TableDesc->Signature.Ascii));
7033446Smrj         }
7043446Smrj     }
7053446Smrj }
7063446Smrj 
7073446Smrj 
7083446Smrj /*******************************************************************************
7093446Smrj  *
7103446Smrj  * FUNCTION:    AcpiDbUnloadAcpiTable
7113446Smrj  *
7123446Smrj  * PARAMETERS:  TableArg        - Name of the table to be unloaded
7133446Smrj  *              InstanceArg     - Which instance of the table to unload (if
7143446Smrj  *                                there are multiple tables of the same type)
7153446Smrj  *
7163446Smrj  * RETURN:      Nonde
7173446Smrj  *
7183446Smrj  * DESCRIPTION: Unload an ACPI table.
7193446Smrj  *              Instance is not implemented
7203446Smrj  *
7213446Smrj  ******************************************************************************/
7223446Smrj 
7233446Smrj void
AcpiDbUnloadAcpiTable(char * TableArg,char * InstanceArg)7243446Smrj AcpiDbUnloadAcpiTable (
7253446Smrj     char                    *TableArg,
7263446Smrj     char                    *InstanceArg)
7273446Smrj {
7287851SDana.Myers@Sun.COM /* TBD: Need to reimplement for new data structures */
7297851SDana.Myers@Sun.COM 
7307851SDana.Myers@Sun.COM #if 0
7313446Smrj     UINT32                  i;
7323446Smrj     ACPI_STATUS             Status;
7333446Smrj 
7343446Smrj 
7353446Smrj     /* Search all tables for the target type */
7363446Smrj 
7373446Smrj     for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
7383446Smrj     {
7393446Smrj         if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature,
7403446Smrj                 AcpiGbl_TableData[i].SigLength))
7413446Smrj         {
7423446Smrj             /* Found the table, unload it */
7433446Smrj 
7443446Smrj             Status = AcpiUnloadTable (i);
7453446Smrj             if (ACPI_SUCCESS (Status))
7463446Smrj             {
7473446Smrj                 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
7483446Smrj             }
7493446Smrj             else
7503446Smrj             {
7513446Smrj                 AcpiOsPrintf ("%s, while unloading [%s]\n",
7523446Smrj                     AcpiFormatException (Status), TableArg);
7533446Smrj             }
7543446Smrj 
7553446Smrj             return;
7563446Smrj         }
7573446Smrj     }
7583446Smrj 
7593446Smrj     AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
7607851SDana.Myers@Sun.COM #endif
7613446Smrj }
7623446Smrj 
7633446Smrj 
7643446Smrj /*******************************************************************************
7653446Smrj  *
7663446Smrj  * FUNCTION:    AcpiDbSetMethodBreakpoint
7673446Smrj  *
7683446Smrj  * PARAMETERS:  Location            - AML offset of breakpoint
7693446Smrj  *              WalkState           - Current walk info
7703446Smrj  *              Op                  - Current Op (from parse walk)
7713446Smrj  *
7723446Smrj  * RETURN:      None
7733446Smrj  *
7743446Smrj  * DESCRIPTION: Set a breakpoint in a control method at the specified
7753446Smrj  *              AML offset
7763446Smrj  *
7773446Smrj  ******************************************************************************/
7783446Smrj 
7793446Smrj void
AcpiDbSetMethodBreakpoint(char * Location,ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op)7803446Smrj AcpiDbSetMethodBreakpoint (
7813446Smrj     char                    *Location,
7823446Smrj     ACPI_WALK_STATE         *WalkState,
7833446Smrj     ACPI_PARSE_OBJECT       *Op)
7843446Smrj {
7853446Smrj     UINT32                  Address;
7863446Smrj 
7873446Smrj 
7883446Smrj     if (!Op)
7893446Smrj     {
7903446Smrj         AcpiOsPrintf ("There is no method currently executing\n");
7913446Smrj         return;
7923446Smrj     }
7933446Smrj 
7943446Smrj     /* Get and verify the breakpoint address */
7953446Smrj 
7963446Smrj     Address = ACPI_STRTOUL (Location, NULL, 16);
7973446Smrj     if (Address <= Op->Common.AmlOffset)
7983446Smrj     {
7993446Smrj         AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
8003446Smrj             Address, Op->Common.AmlOffset);
8013446Smrj     }
8023446Smrj 
8033446Smrj     /* Save breakpoint in current walk */
8043446Smrj 
8053446Smrj     WalkState->UserBreakpoint = Address;
8063446Smrj     AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
8073446Smrj }
8083446Smrj 
8093446Smrj 
8103446Smrj /*******************************************************************************
8113446Smrj  *
8123446Smrj  * FUNCTION:    AcpiDbSetMethodCallBreakpoint
8133446Smrj  *
8143446Smrj  * PARAMETERS:  Op                  - Current Op (from parse walk)
8153446Smrj  *
8163446Smrj  * RETURN:      None
8173446Smrj  *
8183446Smrj  * DESCRIPTION: Set a breakpoint in a control method at the specified
8193446Smrj  *              AML offset
8203446Smrj  *
8213446Smrj  ******************************************************************************/
8223446Smrj 
8233446Smrj void
AcpiDbSetMethodCallBreakpoint(ACPI_PARSE_OBJECT * Op)8243446Smrj AcpiDbSetMethodCallBreakpoint (
8253446Smrj     ACPI_PARSE_OBJECT       *Op)
8263446Smrj {
8273446Smrj 
8283446Smrj 
8293446Smrj     if (!Op)
8303446Smrj     {
8313446Smrj         AcpiOsPrintf ("There is no method currently executing\n");
8323446Smrj         return;
8333446Smrj     }
8343446Smrj 
8353446Smrj     AcpiGbl_StepToNextCall = TRUE;
8363446Smrj }
8373446Smrj 
8383446Smrj 
8393446Smrj /*******************************************************************************
8403446Smrj  *
8413446Smrj  * FUNCTION:    AcpiDbDisassembleAml
8423446Smrj  *
8433446Smrj  * PARAMETERS:  Statements          - Number of statements to disassemble
8443446Smrj  *              Op                  - Current Op (from parse walk)
8453446Smrj  *
8463446Smrj  * RETURN:      None
8473446Smrj  *
8483446Smrj  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
8493446Smrj  *              of statements specified.
8503446Smrj  *
8513446Smrj  ******************************************************************************/
8523446Smrj 
8533446Smrj void
AcpiDbDisassembleAml(char * Statements,ACPI_PARSE_OBJECT * Op)8543446Smrj AcpiDbDisassembleAml (
8553446Smrj     char                    *Statements,
8563446Smrj     ACPI_PARSE_OBJECT       *Op)
8573446Smrj {
8583446Smrj     UINT32                  NumStatements = 8;
8593446Smrj 
8603446Smrj 
8613446Smrj     if (!Op)
8623446Smrj     {
8633446Smrj         AcpiOsPrintf ("There is no method currently executing\n");
8643446Smrj         return;
8653446Smrj     }
8663446Smrj 
8673446Smrj     if (Statements)
8683446Smrj     {
8693446Smrj         NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
8703446Smrj     }
8713446Smrj 
8723446Smrj     AcpiDmDisassemble (NULL, Op, NumStatements);
8733446Smrj }
8743446Smrj 
8753446Smrj 
8763446Smrj /*******************************************************************************
8773446Smrj  *
8783446Smrj  * FUNCTION:    AcpiDbDisassembleMethod
8793446Smrj  *
8803446Smrj  * PARAMETERS:  Name            - Name of control method
8813446Smrj  *
8823446Smrj  * RETURN:      None
8833446Smrj  *
8843446Smrj  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
8853446Smrj  *              of statements specified.
8863446Smrj  *
8873446Smrj  ******************************************************************************/
8883446Smrj 
8893446Smrj ACPI_STATUS
AcpiDbDisassembleMethod(char * Name)8903446Smrj AcpiDbDisassembleMethod (
8913446Smrj     char                    *Name)
8923446Smrj {
8933446Smrj     ACPI_STATUS             Status;
8943446Smrj     ACPI_PARSE_OBJECT       *Op;
8953446Smrj     ACPI_WALK_STATE         *WalkState;
8963446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
8973446Smrj     ACPI_NAMESPACE_NODE     *Method;
8983446Smrj 
8993446Smrj 
9003446Smrj     Method = AcpiDbConvertToNode (Name);
9013446Smrj     if (!Method)
9023446Smrj     {
9033446Smrj         return (AE_BAD_PARAMETER);
9043446Smrj     }
9053446Smrj 
9063446Smrj     ObjDesc = Method->Object;
9073446Smrj 
9083446Smrj     Op = AcpiPsCreateScopeOp ();
9093446Smrj     if (!Op)
9103446Smrj     {
9113446Smrj         return (AE_NO_MEMORY);
9123446Smrj     }
9133446Smrj 
9143446Smrj     /* Create and initialize a new walk state */
9153446Smrj 
9163446Smrj     WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
9173446Smrj     if (!WalkState)
9183446Smrj     {
9193446Smrj         return (AE_NO_MEMORY);
9203446Smrj     }
9213446Smrj 
9223446Smrj     Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
9233446Smrj                     ObjDesc->Method.AmlStart,
9247851SDana.Myers@Sun.COM                     ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
9253446Smrj     if (ACPI_FAILURE (Status))
9263446Smrj     {
9273446Smrj         return (Status);
9283446Smrj     }
9293446Smrj 
9303446Smrj     /* Parse the AML */
9313446Smrj 
9323446Smrj     WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
9333446Smrj     WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
9343446Smrj     Status = AcpiPsParseAml (WalkState);
9353446Smrj 
9363446Smrj     AcpiDmDisassemble (NULL, Op, 0);
9373446Smrj     AcpiPsDeleteParseTree (Op);
9383446Smrj     return (AE_OK);
9393446Smrj }
9403446Smrj 
9413446Smrj 
9423446Smrj /*******************************************************************************
9433446Smrj  *
9443446Smrj  * FUNCTION:    AcpiDbDumpNamespace
9453446Smrj  *
9463446Smrj  * PARAMETERS:  StartArg        - Node to begin namespace dump
9473446Smrj  *              DepthArg        - Maximum tree depth to be dumped
9483446Smrj  *
9493446Smrj  * RETURN:      None
9503446Smrj  *
9513446Smrj  * DESCRIPTION: Dump entire namespace or a subtree.  Each node is displayed
9523446Smrj  *              with type and other information.
9533446Smrj  *
9543446Smrj  ******************************************************************************/
9553446Smrj 
9563446Smrj void
AcpiDbDumpNamespace(char * StartArg,char * DepthArg)9573446Smrj AcpiDbDumpNamespace (
9583446Smrj     char                    *StartArg,
9593446Smrj     char                    *DepthArg)
9603446Smrj {
9613446Smrj     ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
9623446Smrj     UINT32                  MaxDepth = ACPI_UINT32_MAX;
9633446Smrj 
9643446Smrj 
9653446Smrj     /* No argument given, just start at the root and dump entire namespace */
9663446Smrj 
9673446Smrj     if (StartArg)
9683446Smrj     {
9693446Smrj         SubtreeEntry = AcpiDbConvertToNode (StartArg);
9703446Smrj         if (!SubtreeEntry)
9713446Smrj         {
9723446Smrj             return;
9733446Smrj         }
9743446Smrj 
9753446Smrj         /* Now we can check for the depth argument */
9763446Smrj 
9773446Smrj         if (DepthArg)
9783446Smrj         {
9793446Smrj             MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
9803446Smrj         }
9813446Smrj     }
9823446Smrj 
9833446Smrj     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
9843446Smrj     AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
9853446Smrj         ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
9863446Smrj 
9873446Smrj     /* Display the subtree */
9883446Smrj 
9893446Smrj     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
9903446Smrj     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
9913446Smrj         ACPI_OWNER_ID_MAX, SubtreeEntry);
9923446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
9933446Smrj }
9943446Smrj 
9953446Smrj 
9963446Smrj /*******************************************************************************
9973446Smrj  *
9983446Smrj  * FUNCTION:    AcpiDbDumpNamespaceByOwner
9993446Smrj  *
10003446Smrj  * PARAMETERS:  OwnerArg        - Owner ID whose nodes will be displayed
10013446Smrj  *              DepthArg        - Maximum tree depth to be dumped
10023446Smrj  *
10033446Smrj  * RETURN:      None
10043446Smrj  *
10053446Smrj  * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
10063446Smrj  *
10073446Smrj  ******************************************************************************/
10083446Smrj 
10093446Smrj void
AcpiDbDumpNamespaceByOwner(char * OwnerArg,char * DepthArg)10103446Smrj AcpiDbDumpNamespaceByOwner (
10113446Smrj     char                    *OwnerArg,
10123446Smrj     char                    *DepthArg)
10133446Smrj {
10143446Smrj     ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
10153446Smrj     UINT32                  MaxDepth = ACPI_UINT32_MAX;
10163446Smrj     ACPI_OWNER_ID           OwnerId;
10173446Smrj 
10183446Smrj 
10193446Smrj     OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
10203446Smrj 
10213446Smrj     /* Now we can check for the depth argument */
10223446Smrj 
10233446Smrj     if (DepthArg)
10243446Smrj     {
10253446Smrj         MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
10263446Smrj     }
10273446Smrj 
10283446Smrj     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
10293446Smrj     AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
10303446Smrj 
10313446Smrj     /* Display the subtree */
10323446Smrj 
10333446Smrj     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
10343446Smrj     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId,
10353446Smrj         SubtreeEntry);
10363446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
10373446Smrj }
10383446Smrj 
10393446Smrj 
10403446Smrj /*******************************************************************************
10413446Smrj  *
10423446Smrj  * FUNCTION:    AcpiDbSendNotify
10433446Smrj  *
10443446Smrj  * PARAMETERS:  Name            - Name of ACPI object to send the notify to
10453446Smrj  *              Value           - Value of the notify to send.
10463446Smrj  *
10473446Smrj  * RETURN:      None
10483446Smrj  *
10493446Smrj  * DESCRIPTION: Send an ACPI notification.  The value specified is sent to the
10503446Smrj  *              named object as an ACPI notify.
10513446Smrj  *
10523446Smrj  ******************************************************************************/
10533446Smrj 
10543446Smrj void
AcpiDbSendNotify(char * Name,UINT32 Value)10553446Smrj AcpiDbSendNotify (
10563446Smrj     char                    *Name,
10573446Smrj     UINT32                  Value)
10583446Smrj {
10593446Smrj     ACPI_NAMESPACE_NODE     *Node;
10603446Smrj     ACPI_STATUS             Status;
10613446Smrj 
10623446Smrj 
10633446Smrj     /* Translate name to an Named object */
10643446Smrj 
10653446Smrj     Node = AcpiDbConvertToNode (Name);
10663446Smrj     if (!Node)
10673446Smrj     {
10683446Smrj         return;
10693446Smrj     }
10703446Smrj 
10713446Smrj     /* Decode Named object type */
10723446Smrj 
10733446Smrj     switch (Node->Type)
10743446Smrj     {
10753446Smrj     case ACPI_TYPE_DEVICE:
10763446Smrj     case ACPI_TYPE_THERMAL:
10773446Smrj 
10783446Smrj          /* Send the notify */
10793446Smrj 
10803446Smrj         Status = AcpiEvQueueNotifyRequest (Node, Value);
10813446Smrj         if (ACPI_FAILURE (Status))
10823446Smrj         {
10833446Smrj             AcpiOsPrintf ("Could not queue notify\n");
10843446Smrj         }
10853446Smrj         break;
10863446Smrj 
10873446Smrj     default:
10883446Smrj         AcpiOsPrintf ("Named object is not a device or a thermal object\n");
10893446Smrj         break;
10903446Smrj     }
10913446Smrj }
10923446Smrj 
10933446Smrj 
10943446Smrj /*******************************************************************************
10953446Smrj  *
10963446Smrj  * FUNCTION:    AcpiDbSetMethodData
10973446Smrj  *
10983446Smrj  * PARAMETERS:  TypeArg         - L for local, A for argument
10993446Smrj  *              IndexArg        - which one
11003446Smrj  *              ValueArg        - Value to set.
11013446Smrj  *
11023446Smrj  * RETURN:      None
11033446Smrj  *
11043446Smrj  * DESCRIPTION: Set a local or argument for the running control method.
11053446Smrj  *              NOTE: only object supported is Number.
11063446Smrj  *
11073446Smrj  ******************************************************************************/
11083446Smrj 
11093446Smrj void
AcpiDbSetMethodData(char * TypeArg,char * IndexArg,char * ValueArg)11103446Smrj AcpiDbSetMethodData (
11113446Smrj     char                    *TypeArg,
11123446Smrj     char                    *IndexArg,
11133446Smrj     char                    *ValueArg)
11143446Smrj {
11153446Smrj     char                    Type;
11163446Smrj     UINT32                  Index;
11173446Smrj     UINT32                  Value;
11183446Smrj     ACPI_WALK_STATE         *WalkState;
11193446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
11203446Smrj     ACPI_STATUS             Status;
11213446Smrj     ACPI_NAMESPACE_NODE     *Node;
11223446Smrj 
11233446Smrj 
11243446Smrj     /* Validate TypeArg */
11253446Smrj 
11263446Smrj     AcpiUtStrupr (TypeArg);
11273446Smrj     Type = TypeArg[0];
11283446Smrj     if ((Type != 'L') &&
11293446Smrj         (Type != 'A') &&
11303446Smrj         (Type != 'N'))
11313446Smrj     {
11323446Smrj         AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
11333446Smrj         return;
11343446Smrj     }
11353446Smrj 
11363446Smrj     Value = ACPI_STRTOUL (ValueArg, NULL, 16);
11373446Smrj 
11383446Smrj     if (Type == 'N')
11393446Smrj     {
11403446Smrj         Node = AcpiDbConvertToNode (IndexArg);
11413446Smrj         if (Node->Type != ACPI_TYPE_INTEGER)
11423446Smrj         {
11433446Smrj             AcpiOsPrintf ("Can only set Integer nodes\n");
11443446Smrj             return;
11453446Smrj         }
11463446Smrj         ObjDesc = Node->Object;
11473446Smrj         ObjDesc->Integer.Value = Value;
11483446Smrj         return;
11493446Smrj     }
11503446Smrj 
11513446Smrj     /* Get the index and value */
11523446Smrj 
11533446Smrj     Index = ACPI_STRTOUL (IndexArg, NULL, 16);
11543446Smrj 
11553446Smrj     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
11563446Smrj     if (!WalkState)
11573446Smrj     {
11583446Smrj         AcpiOsPrintf ("There is no method currently executing\n");
11593446Smrj         return;
11603446Smrj     }
11613446Smrj 
11623446Smrj     /* Create and initialize the new object */
11633446Smrj 
1164*11225SDana.Myers@Sun.COM     ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value);
11653446Smrj     if (!ObjDesc)
11663446Smrj     {
11673446Smrj         AcpiOsPrintf ("Could not create an internal object\n");
11683446Smrj         return;
11693446Smrj     }
11703446Smrj 
11713446Smrj     /* Store the new object into the target */
11723446Smrj 
11733446Smrj     switch (Type)
11743446Smrj     {
11753446Smrj     case 'A':
11763446Smrj 
11773446Smrj         /* Set a method argument */
11783446Smrj 
11793446Smrj         if (Index > ACPI_METHOD_MAX_ARG)
11803446Smrj         {
11813446Smrj             AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
11823446Smrj             goto Cleanup;
11833446Smrj         }
11843446Smrj 
11857851SDana.Myers@Sun.COM         Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc,
11863446Smrj                     WalkState);
11873446Smrj         if (ACPI_FAILURE (Status))
11883446Smrj         {
11893446Smrj             goto Cleanup;
11903446Smrj         }
11913446Smrj 
11923446Smrj         ObjDesc = WalkState->Arguments[Index].Object;
11933446Smrj 
11943446Smrj         AcpiOsPrintf ("Arg%d: ", Index);
11953446Smrj         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
11963446Smrj         break;
11973446Smrj 
11983446Smrj     case 'L':
11993446Smrj 
12003446Smrj         /* Set a method local */
12013446Smrj 
12023446Smrj         if (Index > ACPI_METHOD_MAX_LOCAL)
12033446Smrj         {
12043446Smrj             AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
12053446Smrj             goto Cleanup;
12063446Smrj         }
12073446Smrj 
12087851SDana.Myers@Sun.COM         Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc,
12093446Smrj                     WalkState);
12103446Smrj         if (ACPI_FAILURE (Status))
12113446Smrj         {
12123446Smrj             goto Cleanup;
12133446Smrj         }
12143446Smrj 
12153446Smrj         ObjDesc = WalkState->LocalVariables[Index].Object;
12163446Smrj 
12173446Smrj         AcpiOsPrintf ("Local%d: ", Index);
12183446Smrj         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
12193446Smrj         break;
12203446Smrj 
12213446Smrj     default:
12223446Smrj         break;
12233446Smrj     }
12243446Smrj 
12253446Smrj Cleanup:
12263446Smrj     AcpiUtRemoveReference (ObjDesc);
12273446Smrj }
12283446Smrj 
12293446Smrj 
12303446Smrj /*******************************************************************************
12313446Smrj  *
12323446Smrj  * FUNCTION:    AcpiDbWalkForSpecificObjects
12333446Smrj  *
12343446Smrj  * PARAMETERS:  Callback from WalkNamespace
12353446Smrj  *
12363446Smrj  * RETURN:      Status
12373446Smrj  *
12383446Smrj  * DESCRIPTION: Display short info about objects in the namespace
12393446Smrj  *
12403446Smrj  ******************************************************************************/
12413446Smrj 
12423446Smrj static ACPI_STATUS
AcpiDbWalkForSpecificObjects(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)12433446Smrj AcpiDbWalkForSpecificObjects (
12443446Smrj     ACPI_HANDLE             ObjHandle,
12453446Smrj     UINT32                  NestingLevel,
12463446Smrj     void                    *Context,
12473446Smrj     void                    **ReturnValue)
12483446Smrj {
12493446Smrj     ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
12503446Smrj     ACPI_BUFFER             Buffer;
12513446Smrj     ACPI_STATUS             Status;
12523446Smrj 
12533446Smrj 
12543446Smrj     Info->Count++;
12553446Smrj 
12563446Smrj     /* Get and display the full pathname to this object */
12573446Smrj 
12583446Smrj     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
12593446Smrj     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
12603446Smrj     if (ACPI_FAILURE (Status))
12613446Smrj     {
12623446Smrj         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
12633446Smrj         return (AE_OK);
12643446Smrj     }
12653446Smrj 
12663446Smrj     AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
12673446Smrj     ACPI_FREE (Buffer.Pointer);
12683446Smrj 
12693446Smrj     /* Dump short info about the object */
12703446Smrj 
12713446Smrj     (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
12723446Smrj     return (AE_OK);
12733446Smrj }
12743446Smrj 
12753446Smrj 
12763446Smrj /*******************************************************************************
12773446Smrj  *
12783446Smrj  * FUNCTION:    AcpiDbDisplayObjects
12793446Smrj  *
12803446Smrj  * PARAMETERS:  ObjTypeArg          - Type of object to display
12813446Smrj  *              DisplayCountArg     - Max depth to display
12823446Smrj  *
12833446Smrj  * RETURN:      None
12843446Smrj  *
12853446Smrj  * DESCRIPTION: Display objects in the namespace of the requested type
12863446Smrj  *
12873446Smrj  ******************************************************************************/
12883446Smrj 
12893446Smrj ACPI_STATUS
AcpiDbDisplayObjects(char * ObjTypeArg,char * DisplayCountArg)12903446Smrj AcpiDbDisplayObjects (
12913446Smrj     char                    *ObjTypeArg,
12923446Smrj     char                    *DisplayCountArg)
12933446Smrj {
12943446Smrj     ACPI_WALK_INFO          Info;
12953446Smrj     ACPI_OBJECT_TYPE        Type;
12963446Smrj 
12973446Smrj 
12983446Smrj     /* Get the object type */
12993446Smrj 
13003446Smrj     Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
13013446Smrj     if (Type == ACPI_TYPE_NOT_FOUND)
13023446Smrj     {
13033446Smrj         AcpiOsPrintf ("Invalid or unsupported argument\n");
13043446Smrj         return (AE_OK);
13053446Smrj     }
13063446Smrj 
13073446Smrj     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
13083446Smrj     AcpiOsPrintf (
13093446Smrj         "Objects of type [%s] defined in the current ACPI Namespace:\n",
13103446Smrj         AcpiUtGetTypeName (Type));
13113446Smrj 
13123446Smrj     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
13133446Smrj 
13143446Smrj     Info.Count = 0;
13153446Smrj     Info.OwnerId = ACPI_OWNER_ID_MAX;
13163446Smrj     Info.DebugLevel = ACPI_UINT32_MAX;
13173446Smrj     Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
13183446Smrj 
13193446Smrj     /* Walk the namespace from the root */
13203446Smrj 
13213446Smrj     (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1322*11225SDana.Myers@Sun.COM                 AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL);
13233446Smrj 
13243446Smrj     AcpiOsPrintf (
13253446Smrj         "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
13263446Smrj         Info.Count, AcpiUtGetTypeName (Type));
13273446Smrj 
13283446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
13293446Smrj     return (AE_OK);
13303446Smrj }
13313446Smrj 
13323446Smrj 
13333446Smrj /*******************************************************************************
13343446Smrj  *
13353446Smrj  * FUNCTION:    AcpiDbWalkAndMatchName
13363446Smrj  *
13373446Smrj  * PARAMETERS:  Callback from WalkNamespace
13383446Smrj  *
13393446Smrj  * RETURN:      Status
13403446Smrj  *
13413446Smrj  * DESCRIPTION: Find a particular name/names within the namespace.  Wildcards
13423446Smrj  *              are supported -- '?' matches any character.
13433446Smrj  *
13443446Smrj  ******************************************************************************/
13453446Smrj 
13463446Smrj static ACPI_STATUS
AcpiDbWalkAndMatchName(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)13473446Smrj AcpiDbWalkAndMatchName (
13483446Smrj     ACPI_HANDLE             ObjHandle,
13493446Smrj     UINT32                  NestingLevel,
13503446Smrj     void                    *Context,
13513446Smrj     void                    **ReturnValue)
13523446Smrj {
13533446Smrj     ACPI_STATUS             Status;
13543446Smrj     char                    *RequestedName = (char *) Context;
13553446Smrj     UINT32                  i;
13563446Smrj     ACPI_BUFFER             Buffer;
13573446Smrj     ACPI_WALK_INFO          Info;
13583446Smrj 
13593446Smrj 
13603446Smrj     /* Check for a name match */
13613446Smrj 
13623446Smrj     for (i = 0; i < 4; i++)
13633446Smrj     {
13643446Smrj         /* Wildcard support */
13653446Smrj 
13663446Smrj         if ((RequestedName[i] != '?') &&
13673446Smrj             (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
13683446Smrj         {
13693446Smrj             /* No match, just exit */
13703446Smrj 
13713446Smrj             return (AE_OK);
13723446Smrj         }
13733446Smrj     }
13743446Smrj 
13753446Smrj     /* Get the full pathname to this object */
13763446Smrj 
13773446Smrj     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
13783446Smrj     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
13793446Smrj     if (ACPI_FAILURE (Status))
13803446Smrj     {
13813446Smrj         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
13823446Smrj     }
13833446Smrj     else
13843446Smrj     {
13853446Smrj         Info.OwnerId = ACPI_OWNER_ID_MAX;
13863446Smrj         Info.DebugLevel = ACPI_UINT32_MAX;
13873446Smrj         Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
13883446Smrj 
13893446Smrj         AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
13903446Smrj         (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
13913446Smrj         ACPI_FREE (Buffer.Pointer);
13923446Smrj     }
13933446Smrj 
13943446Smrj     return (AE_OK);
13953446Smrj }
13963446Smrj 
13973446Smrj 
13983446Smrj /*******************************************************************************
13993446Smrj  *
14003446Smrj  * FUNCTION:    AcpiDbFindNameInNamespace
14013446Smrj  *
14023446Smrj  * PARAMETERS:  NameArg         - The 4-character ACPI name to find.
14033446Smrj  *                                wildcards are supported.
14043446Smrj  *
14053446Smrj  * RETURN:      None
14063446Smrj  *
14073446Smrj  * DESCRIPTION: Search the namespace for a given name (with wildcards)
14083446Smrj  *
14093446Smrj  ******************************************************************************/
14103446Smrj 
14113446Smrj ACPI_STATUS
AcpiDbFindNameInNamespace(char * NameArg)14123446Smrj AcpiDbFindNameInNamespace (
14133446Smrj     char                    *NameArg)
14143446Smrj {
14159980SDana.Myers@Sun.COM     char                    AcpiName[5] = "____";
14169980SDana.Myers@Sun.COM     char                    *AcpiNamePtr = AcpiName;
14179980SDana.Myers@Sun.COM 
14183446Smrj 
14193446Smrj     if (ACPI_STRLEN (NameArg) > 4)
14203446Smrj     {
14213446Smrj         AcpiOsPrintf ("Name must be no longer than 4 characters\n");
14223446Smrj         return (AE_OK);
14233446Smrj     }
14243446Smrj 
14259980SDana.Myers@Sun.COM     /* Pad out name with underscores as necessary to create a 4-char name */
14263446Smrj 
14273446Smrj     AcpiUtStrupr (NameArg);
14289980SDana.Myers@Sun.COM     while (*NameArg)
14299980SDana.Myers@Sun.COM     {
14309980SDana.Myers@Sun.COM         *AcpiNamePtr = *NameArg;
14319980SDana.Myers@Sun.COM         AcpiNamePtr++;
14329980SDana.Myers@Sun.COM         NameArg++;
14339980SDana.Myers@Sun.COM     }
14349980SDana.Myers@Sun.COM 
14359980SDana.Myers@Sun.COM     /* Walk the namespace from the root */
14369980SDana.Myers@Sun.COM 
14373446Smrj     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1438*11225SDana.Myers@Sun.COM                         AcpiDbWalkAndMatchName, NULL, AcpiName, NULL);
14393446Smrj 
14403446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
14413446Smrj     return (AE_OK);
14423446Smrj }
14433446Smrj 
14443446Smrj 
14453446Smrj /*******************************************************************************
14463446Smrj  *
14473446Smrj  * FUNCTION:    AcpiDbSetScope
14483446Smrj  *
14493446Smrj  * PARAMETERS:  Name                - New scope path
14503446Smrj  *
14513446Smrj  * RETURN:      Status
14523446Smrj  *
14533446Smrj  * DESCRIPTION: Set the "current scope" as maintained by this utility.
14543446Smrj  *              The scope is used as a prefix to ACPI paths.
14553446Smrj  *
14563446Smrj  ******************************************************************************/
14573446Smrj 
14583446Smrj void
AcpiDbSetScope(char * Name)14593446Smrj AcpiDbSetScope (
14603446Smrj     char                    *Name)
14613446Smrj {
14623446Smrj     ACPI_STATUS             Status;
14633446Smrj     ACPI_NAMESPACE_NODE     *Node;
14643446Smrj 
14653446Smrj 
14663446Smrj     if (!Name || Name[0] == 0)
14673446Smrj     {
14683446Smrj         AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
14693446Smrj         return;
14703446Smrj     }
14713446Smrj 
14723446Smrj     AcpiDbPrepNamestring (Name);
14733446Smrj 
14743446Smrj     if (Name[0] == '\\')
14753446Smrj     {
14763446Smrj         /* Validate new scope from the root */
14773446Smrj 
14783446Smrj         Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
14793446Smrj                     &Node);
14803446Smrj         if (ACPI_FAILURE (Status))
14813446Smrj         {
14823446Smrj             goto ErrorExit;
14833446Smrj         }
14843446Smrj 
14853446Smrj         ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
14863446Smrj         ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
14873446Smrj     }
14883446Smrj     else
14893446Smrj     {
14903446Smrj         /* Validate new scope relative to old scope */
14913446Smrj 
14923446Smrj         Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
14933446Smrj                     &Node);
14943446Smrj         if (ACPI_FAILURE (Status))
14953446Smrj         {
14963446Smrj             goto ErrorExit;
14973446Smrj         }
14983446Smrj 
14993446Smrj         ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
15003446Smrj         ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
15013446Smrj     }
15023446Smrj 
15033446Smrj     AcpiGbl_DbScopeNode = Node;
15043446Smrj     AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
15053446Smrj     return;
15063446Smrj 
15073446Smrj ErrorExit:
15083446Smrj 
15093446Smrj     AcpiOsPrintf ("Could not attach scope: %s, %s\n",
15103446Smrj         Name, AcpiFormatException (Status));
15113446Smrj }
15123446Smrj 
15133446Smrj 
15143446Smrj /*******************************************************************************
15153446Smrj  *
15163446Smrj  * FUNCTION:    AcpiDmCompareAmlResources
15173446Smrj  *
15183446Smrj  * PARAMETERS:  Aml1Buffer          - Contains first resource list
15193446Smrj  *              Aml1BufferLength    - Length of first resource list
15203446Smrj  *              Aml2Buffer          - Contains second resource list
15213446Smrj  *              Aml2BufferLength    - Length of second resource list
15223446Smrj  *
15233446Smrj  * RETURN:      None
15243446Smrj  *
15253446Smrj  * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
15263446Smrj  *              order to isolate a miscompare to an individual resource)
15273446Smrj  *
15283446Smrj  ******************************************************************************/
15293446Smrj 
15303446Smrj static void
AcpiDmCompareAmlResources(UINT8 * Aml1Buffer,ACPI_RSDESC_SIZE Aml1BufferLength,UINT8 * Aml2Buffer,ACPI_RSDESC_SIZE Aml2BufferLength)15313446Smrj AcpiDmCompareAmlResources (
15323446Smrj     UINT8                   *Aml1Buffer,
15333446Smrj     ACPI_RSDESC_SIZE        Aml1BufferLength,
15343446Smrj     UINT8                   *Aml2Buffer,
15353446Smrj     ACPI_RSDESC_SIZE        Aml2BufferLength)
15363446Smrj {
15373446Smrj     UINT8                   *Aml1;
15383446Smrj     UINT8                   *Aml2;
15393446Smrj     ACPI_RSDESC_SIZE        Aml1Length;
15403446Smrj     ACPI_RSDESC_SIZE        Aml2Length;
15413446Smrj     ACPI_RSDESC_SIZE        Offset = 0;
15423446Smrj     UINT8                   ResourceType;
15433446Smrj     UINT32                  Count = 0;
15443446Smrj 
15453446Smrj 
15463446Smrj     /* Compare overall buffer sizes (may be different due to size rounding) */
15473446Smrj 
15483446Smrj     if (Aml1BufferLength != Aml2BufferLength)
15493446Smrj     {
15503446Smrj         AcpiOsPrintf (
15513446Smrj             "**** Buffer length mismatch in converted AML: original %X new %X ****\n",
15523446Smrj             Aml1BufferLength, Aml2BufferLength);
15533446Smrj     }
15543446Smrj 
15553446Smrj     Aml1 = Aml1Buffer;
15563446Smrj     Aml2 = Aml2Buffer;
15573446Smrj 
15583446Smrj     /* Walk the descriptor lists, comparing each descriptor */
15593446Smrj 
15603446Smrj     while (Aml1 < (Aml1Buffer + Aml1BufferLength))
15613446Smrj     {
15623446Smrj         /* Get the lengths of each descriptor */
15633446Smrj 
15643446Smrj         Aml1Length = AcpiUtGetDescriptorLength (Aml1);
15653446Smrj         Aml2Length = AcpiUtGetDescriptorLength (Aml2);
15663446Smrj         ResourceType = AcpiUtGetResourceType (Aml1);
15673446Smrj 
15683446Smrj         /* Check for descriptor length match */
15693446Smrj 
15703446Smrj         if (Aml1Length != Aml2Length)
15713446Smrj         {
15723446Smrj             AcpiOsPrintf (
15733446Smrj                 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n",
15743446Smrj                 Count, ResourceType, Offset, Aml1Length, Aml2Length);
15753446Smrj         }
15763446Smrj 
15773446Smrj         /* Check for descriptor byte match */
15783446Smrj 
15793446Smrj         else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
15803446Smrj         {
15813446Smrj             AcpiOsPrintf (
15823446Smrj                 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
15833446Smrj                 Count, ResourceType, Offset);
15843446Smrj         }
15853446Smrj 
15863446Smrj         /* Exit on EndTag descriptor */
15873446Smrj 
15883446Smrj         if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
15893446Smrj         {
15903446Smrj             return;
15913446Smrj         }
15923446Smrj 
15933446Smrj         /* Point to next descriptor in each buffer */
15943446Smrj 
15953446Smrj         Count++;
15963446Smrj         Offset += Aml1Length;
15973446Smrj         Aml1 += Aml1Length;
15983446Smrj         Aml2 += Aml2Length;
15993446Smrj     }
16003446Smrj }
16013446Smrj 
16023446Smrj 
16033446Smrj /*******************************************************************************
16043446Smrj  *
16053446Smrj  * FUNCTION:    AcpiDmTestResourceConversion
16063446Smrj  *
16073446Smrj  * PARAMETERS:  Node            - Parent device node
16083446Smrj  *              Name            - resource method name (_CRS)
16093446Smrj  *
16103446Smrj  * RETURN:      Status
16113446Smrj  *
16123446Smrj  * DESCRIPTION: Compare the original AML with a conversion of the AML to
16133446Smrj  *              internal resource list, then back to AML.
16143446Smrj  *
16153446Smrj  ******************************************************************************/
16163446Smrj 
16173446Smrj static ACPI_STATUS
AcpiDmTestResourceConversion(ACPI_NAMESPACE_NODE * Node,char * Name)16183446Smrj AcpiDmTestResourceConversion (
16193446Smrj     ACPI_NAMESPACE_NODE     *Node,
16203446Smrj     char                    *Name)
16213446Smrj {
16223446Smrj     ACPI_STATUS             Status;
16233446Smrj     ACPI_BUFFER             ReturnObj;
16243446Smrj     ACPI_BUFFER             ResourceObj;
16253446Smrj     ACPI_BUFFER             NewAml;
16263446Smrj     ACPI_OBJECT             *OriginalAml;
16273446Smrj 
16283446Smrj 
16293446Smrj     AcpiOsPrintf ("Resource Conversion Comparison:\n");
16303446Smrj 
16313446Smrj     NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
16323446Smrj     ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
16333446Smrj     ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
16343446Smrj 
16353446Smrj     /* Get the original _CRS AML resource template */
16363446Smrj 
16373446Smrj     Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj);
16383446Smrj     if (ACPI_FAILURE (Status))
16393446Smrj     {
16403446Smrj         AcpiOsPrintf ("Could not obtain %s: %s\n",
16413446Smrj             Name, AcpiFormatException (Status));
16423446Smrj         return (Status);
16433446Smrj     }
16443446Smrj 
16453446Smrj     /* Get the AML resource template, converted to internal resource structs */
16463446Smrj 
16473446Smrj     Status = AcpiGetCurrentResources (Node, &ResourceObj);
16483446Smrj     if (ACPI_FAILURE (Status))
16493446Smrj     {
16503446Smrj         AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
16513446Smrj             AcpiFormatException (Status));
16523446Smrj         goto Exit1;
16533446Smrj     }
16543446Smrj 
16553446Smrj     /* Convert internal resource list to external AML resource template */
16563446Smrj 
16573446Smrj     Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml);
16583446Smrj     if (ACPI_FAILURE (Status))
16593446Smrj     {
16603446Smrj         AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
16613446Smrj             AcpiFormatException (Status));
16623446Smrj         goto Exit2;
16633446Smrj     }
16643446Smrj 
16653446Smrj     /* Compare original AML to the newly created AML resource list */
16663446Smrj 
16673446Smrj     OriginalAml = ReturnObj.Pointer;
16683446Smrj 
16693446Smrj     AcpiDmCompareAmlResources (
16707851SDana.Myers@Sun.COM         OriginalAml->Buffer.Pointer, (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
16717851SDana.Myers@Sun.COM         NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
16723446Smrj 
16733446Smrj     /* Cleanup and exit */
16743446Smrj 
16753446Smrj     ACPI_FREE (NewAml.Pointer);
16763446Smrj Exit2:
16773446Smrj     ACPI_FREE (ResourceObj.Pointer);
16783446Smrj Exit1:
16793446Smrj     ACPI_FREE (ReturnObj.Pointer);
16803446Smrj     return (Status);
16813446Smrj }
16823446Smrj 
16833446Smrj 
16843446Smrj /*******************************************************************************
16853446Smrj  *
16863446Smrj  * FUNCTION:    AcpiDbDisplayResources
16873446Smrj  *
16883446Smrj  * PARAMETERS:  ObjectArg       - String with hex value of the object
16893446Smrj  *
16903446Smrj  * RETURN:      None
16913446Smrj  *
16923446Smrj  * DESCRIPTION: Display the resource objects associated with a device.
16933446Smrj  *
16943446Smrj  ******************************************************************************/
16953446Smrj 
16963446Smrj void
AcpiDbDisplayResources(char * ObjectArg)16973446Smrj AcpiDbDisplayResources (
16983446Smrj     char                    *ObjectArg)
16993446Smrj {
17003446Smrj     ACPI_NAMESPACE_NODE     *Node;
17013446Smrj     ACPI_STATUS             Status;
17023446Smrj     ACPI_BUFFER             ReturnObj;
17033446Smrj 
17043446Smrj 
17053446Smrj     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
17063446Smrj     AcpiDbgLevel |= ACPI_LV_RESOURCES;
17073446Smrj 
17083446Smrj     /* Convert string to object pointer */
17093446Smrj 
17103446Smrj     Node = AcpiDbConvertToNode (ObjectArg);
17113446Smrj     if (!Node)
17123446Smrj     {
17133446Smrj         return;
17143446Smrj     }
17153446Smrj 
17163446Smrj     /* Prepare for a return object of arbitrary size */
17173446Smrj 
17183446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
17193446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
17203446Smrj 
17213446Smrj     /* _PRT */
17223446Smrj 
17233446Smrj     AcpiOsPrintf ("Evaluating _PRT\n");
17243446Smrj 
17253446Smrj     /* Check if _PRT exists */
17263446Smrj 
17273446Smrj     Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj);
17283446Smrj     if (ACPI_FAILURE (Status))
17293446Smrj     {
17303446Smrj         AcpiOsPrintf ("Could not obtain _PRT: %s\n",
17313446Smrj             AcpiFormatException (Status));
17323446Smrj         goto GetCrs;
17333446Smrj     }
17343446Smrj 
17353446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
17363446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
17373446Smrj 
17383446Smrj     Status = AcpiGetIrqRoutingTable (Node, &ReturnObj);
17393446Smrj     if (ACPI_FAILURE (Status))
17403446Smrj     {
17413446Smrj         AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
17423446Smrj             AcpiFormatException (Status));
17433446Smrj         goto GetCrs;
17443446Smrj     }
17453446Smrj 
17463446Smrj     AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
17473446Smrj 
17483446Smrj 
17493446Smrj     /* _CRS */
17503446Smrj 
17513446Smrj GetCrs:
17523446Smrj     AcpiOsPrintf ("Evaluating _CRS\n");
17533446Smrj 
17543446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
17553446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
17563446Smrj 
17573446Smrj     /* Check if _CRS exists */
17583446Smrj 
17593446Smrj     Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj);
17603446Smrj     if (ACPI_FAILURE (Status))
17613446Smrj     {
17623446Smrj         AcpiOsPrintf ("Could not obtain _CRS: %s\n",
17633446Smrj             AcpiFormatException (Status));
17643446Smrj         goto GetPrs;
17653446Smrj     }
17663446Smrj 
17673446Smrj     /* Get the _CRS resource list */
17683446Smrj 
17693446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
17703446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
17713446Smrj 
17723446Smrj     Status = AcpiGetCurrentResources (Node, &ReturnObj);
17733446Smrj     if (ACPI_FAILURE (Status))
17743446Smrj     {
17753446Smrj         AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
17763446Smrj             AcpiFormatException (Status));
17773446Smrj         goto GetPrs;
17783446Smrj     }
17793446Smrj 
17803446Smrj     /* Dump the _CRS resource list */
17813446Smrj 
17823446Smrj     AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
17833446Smrj         ReturnObj.Pointer));
17843446Smrj 
17853446Smrj     /*
17863446Smrj      * Perform comparison of original AML to newly created AML. This tests both
17873446Smrj      * the AML->Resource conversion and the Resource->Aml conversion.
17883446Smrj      */
17893446Smrj     Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
17903446Smrj 
17913446Smrj     /* Execute _SRS with the resource list */
17923446Smrj 
17933446Smrj     Status = AcpiSetCurrentResources (Node, &ReturnObj);
17943446Smrj     if (ACPI_FAILURE (Status))
17953446Smrj     {
17963446Smrj         AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
17973446Smrj             AcpiFormatException (Status));
17983446Smrj         goto GetPrs;
17993446Smrj     }
18003446Smrj 
18013446Smrj 
18023446Smrj     /* _PRS */
18033446Smrj 
18043446Smrj GetPrs:
18053446Smrj     AcpiOsPrintf ("Evaluating _PRS\n");
18063446Smrj 
18073446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
18083446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
18093446Smrj 
18103446Smrj     /* Check if _PRS exists */
18113446Smrj 
18123446Smrj     Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj);
18133446Smrj     if (ACPI_FAILURE (Status))
18143446Smrj     {
18153446Smrj         AcpiOsPrintf ("Could not obtain _PRS: %s\n",
18163446Smrj             AcpiFormatException (Status));
18173446Smrj         goto Cleanup;
18183446Smrj     }
18193446Smrj 
18203446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
18213446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
18223446Smrj 
18233446Smrj     Status = AcpiGetPossibleResources (Node, &ReturnObj);
18243446Smrj     if (ACPI_FAILURE (Status))
18253446Smrj     {
18263446Smrj         AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
18273446Smrj             AcpiFormatException (Status));
18283446Smrj         goto Cleanup;
18293446Smrj     }
18303446Smrj 
18313446Smrj     AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
18323446Smrj 
18333446Smrj Cleanup:
18343446Smrj 
18353446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
18363446Smrj     return;
18373446Smrj }
18383446Smrj 
18393446Smrj 
18403446Smrj /*******************************************************************************
18413446Smrj  *
18423446Smrj  * FUNCTION:    AcpiDbIntegrityWalk
18433446Smrj  *
18443446Smrj  * PARAMETERS:  Callback from WalkNamespace
18453446Smrj  *
18463446Smrj  * RETURN:      Status
18473446Smrj  *
18483446Smrj  * DESCRIPTION: Examine one NS node for valid values.
18493446Smrj  *
18503446Smrj  ******************************************************************************/
18513446Smrj 
18523446Smrj static ACPI_STATUS
AcpiDbIntegrityWalk(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)18533446Smrj AcpiDbIntegrityWalk (
18543446Smrj     ACPI_HANDLE             ObjHandle,
18553446Smrj     UINT32                  NestingLevel,
18563446Smrj     void                    *Context,
18573446Smrj     void                    **ReturnValue)
18583446Smrj {
18593446Smrj     ACPI_INTEGRITY_INFO     *Info = (ACPI_INTEGRITY_INFO *) Context;
18603446Smrj     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
18613446Smrj     ACPI_OPERAND_OBJECT     *Object;
18627851SDana.Myers@Sun.COM     BOOLEAN                 Alias = TRUE;
18633446Smrj 
18643446Smrj 
18653446Smrj     Info->Nodes++;
18667851SDana.Myers@Sun.COM 
18677851SDana.Myers@Sun.COM     /* Verify the NS node, and dereference aliases */
18687851SDana.Myers@Sun.COM 
18697851SDana.Myers@Sun.COM     while (Alias)
18703446Smrj     {
18717851SDana.Myers@Sun.COM         if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
18727851SDana.Myers@Sun.COM         {
18737851SDana.Myers@Sun.COM             AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n",
18747851SDana.Myers@Sun.COM                 Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node),
18757851SDana.Myers@Sun.COM                 ACPI_DESC_TYPE_NAMED);
18767851SDana.Myers@Sun.COM             return (AE_OK);
18777851SDana.Myers@Sun.COM         }
18787851SDana.Myers@Sun.COM 
18797851SDana.Myers@Sun.COM         if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
18807851SDana.Myers@Sun.COM             (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
18817851SDana.Myers@Sun.COM         {
18827851SDana.Myers@Sun.COM             Node = (ACPI_NAMESPACE_NODE *) Node->Object;
18837851SDana.Myers@Sun.COM         }
18847851SDana.Myers@Sun.COM         else
18857851SDana.Myers@Sun.COM         {
18867851SDana.Myers@Sun.COM             Alias = FALSE;
18877851SDana.Myers@Sun.COM         }
18883446Smrj     }
18893446Smrj 
18903446Smrj     if (Node->Type > ACPI_TYPE_LOCAL_MAX)
18913446Smrj     {
18923446Smrj         AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
18933446Smrj             Node, Node->Type);
18947851SDana.Myers@Sun.COM         return (AE_OK);
18953446Smrj     }
18963446Smrj 
18973446Smrj     if (!AcpiUtValidAcpiName (Node->Name.Integer))
18983446Smrj     {
18993446Smrj         AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
19007851SDana.Myers@Sun.COM         return (AE_OK);
19013446Smrj     }
19023446Smrj 
19033446Smrj     Object = AcpiNsGetAttachedObject (Node);
19043446Smrj     if (Object)
19053446Smrj     {
19063446Smrj         Info->Objects++;
19073446Smrj         if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
19083446Smrj         {
19093446Smrj             AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
19103446Smrj                 Object, AcpiUtGetDescriptorName (Object));
19113446Smrj         }
19123446Smrj     }
19133446Smrj 
19143446Smrj     return (AE_OK);
19153446Smrj }
19163446Smrj 
19173446Smrj 
19183446Smrj /*******************************************************************************
19193446Smrj  *
19203446Smrj  * FUNCTION:    AcpiDbCheckIntegrity
19213446Smrj  *
19223446Smrj  * PARAMETERS:  None
19233446Smrj  *
19243446Smrj  * RETURN:      None
19253446Smrj  *
19263446Smrj  * DESCRIPTION: Check entire namespace for data structure integrity
19273446Smrj  *
19283446Smrj  ******************************************************************************/
19293446Smrj 
19303446Smrj void
AcpiDbCheckIntegrity(void)19313446Smrj AcpiDbCheckIntegrity (
19323446Smrj     void)
19333446Smrj {
19343446Smrj     ACPI_INTEGRITY_INFO     Info = {0,0};
19353446Smrj 
19363446Smrj     /* Search all nodes in namespace */
19373446Smrj 
19383446Smrj     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1939*11225SDana.Myers@Sun.COM                     AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL);
19403446Smrj 
19413446Smrj     AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n",
19423446Smrj         Info.Nodes, Info.Objects);
19433446Smrj }
19443446Smrj 
19453446Smrj 
19463446Smrj /*******************************************************************************
19473446Smrj  *
19483446Smrj  * FUNCTION:    AcpiDbGenerateGpe
19493446Smrj  *
19503446Smrj  * PARAMETERS:  GpeArg          - Raw GPE number, ascii string
19513446Smrj  *              BlockArg        - GPE block number, ascii string
19523446Smrj  *                                0 or 1 for FADT GPE blocks
19533446Smrj  *
19543446Smrj  * RETURN:      None
19553446Smrj  *
19563446Smrj  * DESCRIPTION: Generate a GPE
19573446Smrj  *
19583446Smrj  ******************************************************************************/
19593446Smrj 
19603446Smrj void
AcpiDbGenerateGpe(char * GpeArg,char * BlockArg)19613446Smrj AcpiDbGenerateGpe (
19623446Smrj     char                    *GpeArg,
19633446Smrj     char                    *BlockArg)
19643446Smrj {
19653446Smrj     UINT32                  BlockNumber;
19663446Smrj     UINT32                  GpeNumber;
19673446Smrj     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
19683446Smrj 
19693446Smrj 
19703446Smrj     GpeNumber   = ACPI_STRTOUL (GpeArg, NULL, 0);
19713446Smrj     BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
19723446Smrj 
19733446Smrj 
19743446Smrj     GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
19753446Smrj         GpeNumber);
19763446Smrj     if (!GpeEventInfo)
19773446Smrj     {
19783446Smrj         AcpiOsPrintf ("Invalid GPE\n");
19793446Smrj         return;
19803446Smrj     }
19813446Smrj 
19823446Smrj     (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber);
19833446Smrj }
19843446Smrj 
19853446Smrj 
19863446Smrj /*******************************************************************************
19873446Smrj  *
19883446Smrj  * FUNCTION:    AcpiDbBusWalk
19893446Smrj  *
19903446Smrj  * PARAMETERS:  Callback from WalkNamespace
19913446Smrj  *
19923446Smrj  * RETURN:      Status
19933446Smrj  *
19943446Smrj  * DESCRIPTION: Display info about device objects that have a corresponding
19953446Smrj  *              _PRT method.
19963446Smrj  *
19973446Smrj  ******************************************************************************/
19983446Smrj 
19993446Smrj static ACPI_STATUS
AcpiDbBusWalk(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)20003446Smrj AcpiDbBusWalk (
20013446Smrj     ACPI_HANDLE             ObjHandle,
20023446Smrj     UINT32                  NestingLevel,
20033446Smrj     void                    *Context,
20043446Smrj     void                    **ReturnValue)
20053446Smrj {
20063446Smrj     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
20073446Smrj     ACPI_STATUS             Status;
20083446Smrj     ACPI_BUFFER             Buffer;
20093446Smrj     ACPI_NAMESPACE_NODE     *TempNode;
2010*11225SDana.Myers@Sun.COM     ACPI_DEVICE_INFO        *Info;
2011*11225SDana.Myers@Sun.COM     UINT32                  i;
20123446Smrj 
20133446Smrj 
2014*11225SDana.Myers@Sun.COM     if ((Node->Type != ACPI_TYPE_DEVICE) &&
2015*11225SDana.Myers@Sun.COM         (Node->Type != ACPI_TYPE_PROCESSOR))
2016*11225SDana.Myers@Sun.COM     {
2017*11225SDana.Myers@Sun.COM         return (AE_OK);
2018*11225SDana.Myers@Sun.COM     }
2019*11225SDana.Myers@Sun.COM 
20203446Smrj     /* Exit if there is no _PRT under this device */
20213446Smrj 
20223446Smrj     Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
20233446Smrj                 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
20243446Smrj     if (ACPI_FAILURE (Status))
20253446Smrj     {
20263446Smrj         return (AE_OK);
20273446Smrj     }
20283446Smrj 
20293446Smrj     /* Get the full path to this device object */
20303446Smrj 
20313446Smrj     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
20323446Smrj     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
20333446Smrj     if (ACPI_FAILURE (Status))
20343446Smrj     {
20353446Smrj         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
20363446Smrj         return (AE_OK);
20373446Smrj     }
20383446Smrj 
2039*11225SDana.Myers@Sun.COM     Status = AcpiGetObjectInfo (ObjHandle, &Info);
2040*11225SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
2041*11225SDana.Myers@Sun.COM     {
2042*11225SDana.Myers@Sun.COM         return (AE_OK);
2043*11225SDana.Myers@Sun.COM     }
2044*11225SDana.Myers@Sun.COM 
20453446Smrj     /* Display the full path */
20463446Smrj 
2047*11225SDana.Myers@Sun.COM     AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type);
20483446Smrj     ACPI_FREE (Buffer.Pointer);
20493446Smrj 
2050*11225SDana.Myers@Sun.COM     if (Info->Flags & ACPI_PCI_ROOT_BRIDGE)
2051*11225SDana.Myers@Sun.COM     {
2052*11225SDana.Myers@Sun.COM         AcpiOsPrintf ("  - Is PCI Root Bridge");
2053*11225SDana.Myers@Sun.COM     }
2054*11225SDana.Myers@Sun.COM     AcpiOsPrintf ("\n");
2055*11225SDana.Myers@Sun.COM 
20563446Smrj     /* _PRT info */
20573446Smrj 
2058*11225SDana.Myers@Sun.COM     AcpiOsPrintf ("_PRT: %p\n", TempNode);
20593446Smrj 
2060*11225SDana.Myers@Sun.COM     /* Dump _ADR, _HID, _UID, _CID */
20613446Smrj 
2062*11225SDana.Myers@Sun.COM     if (Info->Valid & ACPI_VALID_ADR)
20633446Smrj     {
2064*11225SDana.Myers@Sun.COM         AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address));
20653446Smrj     }
20663446Smrj     else
20673446Smrj     {
2068*11225SDana.Myers@Sun.COM         AcpiOsPrintf ("_ADR: <Not Present>\n");
20693446Smrj     }
20703446Smrj 
2071*11225SDana.Myers@Sun.COM     if (Info->Valid & ACPI_VALID_HID)
2072*11225SDana.Myers@Sun.COM     {
2073*11225SDana.Myers@Sun.COM         AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String);
2074*11225SDana.Myers@Sun.COM     }
2075*11225SDana.Myers@Sun.COM     else
2076*11225SDana.Myers@Sun.COM     {
2077*11225SDana.Myers@Sun.COM         AcpiOsPrintf ("_HID: <Not Present>\n");
2078*11225SDana.Myers@Sun.COM     }
20793446Smrj 
2080*11225SDana.Myers@Sun.COM     if (Info->Valid & ACPI_VALID_UID)
20813446Smrj     {
2082*11225SDana.Myers@Sun.COM         AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String);
20833446Smrj     }
20843446Smrj     else
20853446Smrj     {
2086*11225SDana.Myers@Sun.COM         AcpiOsPrintf ("_UID: <Not Present>\n");
20873446Smrj     }
20883446Smrj 
2089*11225SDana.Myers@Sun.COM     if (Info->Valid & ACPI_VALID_CID)
20903446Smrj     {
2091*11225SDana.Myers@Sun.COM         for (i = 0; i < Info->CompatibleIdList.Count; i++)
2092*11225SDana.Myers@Sun.COM         {
2093*11225SDana.Myers@Sun.COM             AcpiOsPrintf ("_CID: %s\n",
2094*11225SDana.Myers@Sun.COM                 Info->CompatibleIdList.Ids[i].String);
2095*11225SDana.Myers@Sun.COM         }
2096*11225SDana.Myers@Sun.COM     }
2097*11225SDana.Myers@Sun.COM     else
2098*11225SDana.Myers@Sun.COM     {
2099*11225SDana.Myers@Sun.COM         AcpiOsPrintf ("_CID: <Not Present>\n");
21003446Smrj     }
21013446Smrj 
2102*11225SDana.Myers@Sun.COM     ACPI_FREE (Info);
21033446Smrj     return (AE_OK);
21043446Smrj }
21053446Smrj 
21063446Smrj 
21073446Smrj /*******************************************************************************
21083446Smrj  *
21093446Smrj  * FUNCTION:    AcpiDbGetBusInfo
21103446Smrj  *
21113446Smrj  * PARAMETERS:  None
21123446Smrj  *
21133446Smrj  * RETURN:      None
21143446Smrj  *
21153446Smrj  * DESCRIPTION: Display info about system busses.
21163446Smrj  *
21173446Smrj  ******************************************************************************/
21183446Smrj 
21193446Smrj void
AcpiDbGetBusInfo(void)21203446Smrj AcpiDbGetBusInfo (
21213446Smrj     void)
21223446Smrj {
21233446Smrj     /* Search all nodes in namespace */
21243446Smrj 
2125*11225SDana.Myers@Sun.COM     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
2126*11225SDana.Myers@Sun.COM                     AcpiDbBusWalk, NULL, NULL, NULL);
21273446Smrj }
21283446Smrj 
21293446Smrj #endif /* ACPI_DEBUGGER */
2130