xref: /onnv-gate/usr/src/uts/intel/io/acpica/debugger/dbcmds.c (revision 9980:13d7f3eec672)
13446Smrj /*******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: dbcmds - debug commands and output routines
43446Smrj  *
53446Smrj  ******************************************************************************/
63446Smrj 
73446Smrj /******************************************************************************
83446Smrj  *
93446Smrj  * 1. Copyright Notice
103446Smrj  *
11*9980SDana.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"
118*9980SDana.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 
1333446Smrj /* Local prototypes */
1343446Smrj 
1353446Smrj static ACPI_STATUS
1363446Smrj AcpiDbIntegrityWalk (
1373446Smrj     ACPI_HANDLE             ObjHandle,
1383446Smrj     UINT32                  NestingLevel,
1393446Smrj     void                    *Context,
1403446Smrj     void                    **ReturnValue);
1413446Smrj 
1423446Smrj static ACPI_STATUS
1433446Smrj AcpiDbWalkAndMatchName (
1443446Smrj     ACPI_HANDLE             ObjHandle,
1453446Smrj     UINT32                  NestingLevel,
1463446Smrj     void                    *Context,
1473446Smrj     void                    **ReturnValue);
1483446Smrj 
1493446Smrj static ACPI_STATUS
1503446Smrj AcpiDbWalkForReferences (
1513446Smrj     ACPI_HANDLE             ObjHandle,
1523446Smrj     UINT32                  NestingLevel,
1533446Smrj     void                    *Context,
1543446Smrj     void                    **ReturnValue);
1553446Smrj 
1563446Smrj static ACPI_STATUS
1573446Smrj AcpiDbWalkForSpecificObjects (
1583446Smrj     ACPI_HANDLE             ObjHandle,
1593446Smrj     UINT32                  NestingLevel,
1603446Smrj     void                    *Context,
1613446Smrj     void                    **ReturnValue);
1623446Smrj 
1633446Smrj static ACPI_NAMESPACE_NODE *
1643446Smrj AcpiDbConvertToNode (
1653446Smrj     char                    *InString);
1663446Smrj 
1673446Smrj static void
1683446Smrj AcpiDmCompareAmlResources (
1693446Smrj     UINT8                   *Aml1Buffer,
1703446Smrj     ACPI_RSDESC_SIZE        Aml1BufferLength,
1713446Smrj     UINT8                   *Aml2Buffer,
1723446Smrj     ACPI_RSDESC_SIZE        Aml2BufferLength);
1733446Smrj 
1743446Smrj static ACPI_STATUS
1753446Smrj AcpiDmTestResourceConversion (
1763446Smrj     ACPI_NAMESPACE_NODE     *Node,
1773446Smrj     char                    *Name);
1783446Smrj 
1793446Smrj 
1803446Smrj /*
1813446Smrj  * Arguments for the Objects command
1823446Smrj  * These object types map directly to the ACPI_TYPES
1833446Smrj  */
1843446Smrj static ARGUMENT_INFO        AcpiDbObjectTypes [] =
1853446Smrj {
1863446Smrj     {"ANY"},
1873446Smrj     {"INTEGERS"},
1883446Smrj     {"STRINGS"},
1893446Smrj     {"BUFFERS"},
1903446Smrj     {"PACKAGES"},
1913446Smrj     {"FIELDS"},
1923446Smrj     {"DEVICES"},
1933446Smrj     {"EVENTS"},
1943446Smrj     {"METHODS"},
1953446Smrj     {"MUTEXES"},
1963446Smrj     {"REGIONS"},
1973446Smrj     {"POWERRESOURCES"},
1983446Smrj     {"PROCESSORS"},
1993446Smrj     {"THERMALZONES"},
2003446Smrj     {"BUFFERFIELDS"},
2013446Smrj     {"DDBHANDLES"},
2023446Smrj     {"DEBUG"},
2033446Smrj     {"REGIONFIELDS"},
2043446Smrj     {"BANKFIELDS"},
2053446Smrj     {"INDEXFIELDS"},
2063446Smrj     {"REFERENCES"},
2073446Smrj     {"ALIAS"},
2083446Smrj     {NULL}           /* Must be null terminated */
2093446Smrj };
2103446Smrj 
2113446Smrj 
2123446Smrj /*******************************************************************************
2133446Smrj  *
2143446Smrj  * FUNCTION:    AcpiDbConvertToNode
2153446Smrj  *
2163446Smrj  * PARAMETERS:  InString        - String to convert
2173446Smrj  *
2183446Smrj  * RETURN:      Pointer to a NS node
2193446Smrj  *
2203446Smrj  * DESCRIPTION: Convert a string to a valid NS pointer.  Handles numeric or
2213446Smrj  *              alpha strings.
2223446Smrj  *
2233446Smrj  ******************************************************************************/
2243446Smrj 
2253446Smrj static ACPI_NAMESPACE_NODE *
2263446Smrj AcpiDbConvertToNode (
2273446Smrj     char                    *InString)
2283446Smrj {
2293446Smrj     ACPI_NAMESPACE_NODE     *Node;
2303446Smrj 
2313446Smrj 
2323446Smrj     if ((*InString >= 0x30) && (*InString <= 0x39))
2333446Smrj     {
2343446Smrj         /* Numeric argument, convert */
2353446Smrj 
2363446Smrj         Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16));
2373446Smrj         if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
2383446Smrj         {
2393446Smrj             AcpiOsPrintf ("Address %p is invalid in this address space\n",
2403446Smrj                 Node);
2413446Smrj             return (NULL);
2423446Smrj         }
2433446Smrj 
2443446Smrj         /* Make sure pointer is valid NS node */
2453446Smrj 
2463446Smrj         if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
2473446Smrj         {
2483446Smrj             AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
2493446Smrj                     Node, AcpiUtGetDescriptorName (Node));
2503446Smrj             return (NULL);
2513446Smrj         }
2523446Smrj     }
2533446Smrj     else
2543446Smrj     {
2553446Smrj         /* Alpha argument */
2563446Smrj         /* The parameter is a name string that must be resolved to a
2573446Smrj          * Named obj
2583446Smrj          */
2593446Smrj         Node = AcpiDbLocalNsLookup (InString);
2603446Smrj         if (!Node)
2613446Smrj         {
2623446Smrj             Node = AcpiGbl_RootNode;
2633446Smrj         }
2643446Smrj     }
2653446Smrj 
2663446Smrj     return (Node);
2673446Smrj }
2683446Smrj 
2693446Smrj 
2703446Smrj /*******************************************************************************
2713446Smrj  *
2723446Smrj  * FUNCTION:    AcpiDbSleep
2733446Smrj  *
2743446Smrj  * PARAMETERS:  ObjectArg       - Desired sleep state (0-5)
2753446Smrj  *
2763446Smrj  * RETURN:      Status
2773446Smrj  *
2783446Smrj  * DESCRIPTION: Simulate a sleep/wake sequence
2793446Smrj  *
2803446Smrj  ******************************************************************************/
2813446Smrj 
2823446Smrj ACPI_STATUS
2833446Smrj AcpiDbSleep (
2843446Smrj     char                    *ObjectArg)
2853446Smrj {
2863446Smrj     ACPI_STATUS             Status;
2873446Smrj     UINT8                   SleepState;
2883446Smrj 
2893446Smrj 
2903446Smrj     SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
2913446Smrj 
2923446Smrj     AcpiOsPrintf ("**** Prepare to sleep ****\n");
2933446Smrj     Status = AcpiEnterSleepStatePrep (SleepState);
2943446Smrj     if (ACPI_FAILURE (Status))
2953446Smrj     {
2963446Smrj         return (Status);
2973446Smrj     }
2983446Smrj 
2993446Smrj     AcpiOsPrintf ("**** Going to sleep ****\n");
3003446Smrj     Status = AcpiEnterSleepState (SleepState);
3013446Smrj     if (ACPI_FAILURE (Status))
3023446Smrj     {
3033446Smrj         return (Status);
3043446Smrj     }
3053446Smrj 
3063446Smrj     AcpiOsPrintf ("**** returning from sleep ****\n");
3073446Smrj     Status = AcpiLeaveSleepState (SleepState);
3083446Smrj 
3093446Smrj     return (Status);
3103446Smrj }
3113446Smrj 
3123446Smrj 
3133446Smrj /*******************************************************************************
3143446Smrj  *
3153446Smrj  * FUNCTION:    AcpiDbWalkForReferences
3163446Smrj  *
3173446Smrj  * PARAMETERS:  Callback from WalkNamespace
3183446Smrj  *
3193446Smrj  * RETURN:      Status
3203446Smrj  *
3213446Smrj  * DESCRIPTION: Check if this namespace object refers to the target object
3223446Smrj  *              that is passed in as the context value.
3233446Smrj  *
3243446Smrj  * Note: Currently doesn't check subobjects within the Node's object
3253446Smrj  *
3263446Smrj  ******************************************************************************/
3273446Smrj 
3283446Smrj static ACPI_STATUS
3293446Smrj AcpiDbWalkForReferences (
3303446Smrj     ACPI_HANDLE             ObjHandle,
3313446Smrj     UINT32                  NestingLevel,
3323446Smrj     void                    *Context,
3333446Smrj     void                    **ReturnValue)
3343446Smrj {
3353446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc = (ACPI_OPERAND_OBJECT  *) Context;
3363446Smrj     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
3373446Smrj 
3383446Smrj 
3393446Smrj     /* Check for match against the namespace node itself */
3403446Smrj 
3413446Smrj     if (Node == (void *) ObjDesc)
3423446Smrj     {
3433446Smrj         AcpiOsPrintf ("Object is a Node [%4.4s]\n",
3443446Smrj             AcpiUtGetNodeName (Node));
3453446Smrj     }
3463446Smrj 
3473446Smrj     /* Check for match against the object attached to the node */
3483446Smrj 
3493446Smrj     if (AcpiNsGetAttachedObject (Node) == ObjDesc)
3503446Smrj     {
3513446Smrj         AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
3523446Smrj             Node, AcpiUtGetNodeName (Node));
3533446Smrj     }
3543446Smrj 
3553446Smrj     return (AE_OK);
3563446Smrj }
3573446Smrj 
3583446Smrj 
3593446Smrj /*******************************************************************************
3603446Smrj  *
3613446Smrj  * FUNCTION:    AcpiDbFindReferences
3623446Smrj  *
3633446Smrj  * PARAMETERS:  ObjectArg       - String with hex value of the object
3643446Smrj  *
3653446Smrj  * RETURN:      None
3663446Smrj  *
3673446Smrj  * DESCRIPTION: Search namespace for all references to the input object
3683446Smrj  *
3693446Smrj  ******************************************************************************/
3703446Smrj 
3713446Smrj void
3723446Smrj AcpiDbFindReferences (
3733446Smrj     char                    *ObjectArg)
3743446Smrj {
3753446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
3763446Smrj 
3773446Smrj 
3783446Smrj     /* Convert string to object pointer */
3793446Smrj 
3803446Smrj     ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
3813446Smrj 
3823446Smrj     /* Search all nodes in namespace */
3833446Smrj 
3843446Smrj     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
3853446Smrj                     AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
3863446Smrj }
3873446Smrj 
3883446Smrj 
3893446Smrj /*******************************************************************************
3903446Smrj  *
391*9980SDana.Myers@Sun.COM  * FUNCTION:    AcpiDbWalkForPredefinedNames
392*9980SDana.Myers@Sun.COM  *
393*9980SDana.Myers@Sun.COM  * PARAMETERS:  Callback from WalkNamespace
394*9980SDana.Myers@Sun.COM  *
395*9980SDana.Myers@Sun.COM  * RETURN:      Status
396*9980SDana.Myers@Sun.COM  *
397*9980SDana.Myers@Sun.COM  * DESCRIPTION: Detect and display predefined ACPI names (names that start with
398*9980SDana.Myers@Sun.COM  *              an underscore)
399*9980SDana.Myers@Sun.COM  *
400*9980SDana.Myers@Sun.COM  ******************************************************************************/
401*9980SDana.Myers@Sun.COM 
402*9980SDana.Myers@Sun.COM static ACPI_STATUS
403*9980SDana.Myers@Sun.COM AcpiDbWalkForPredefinedNames (
404*9980SDana.Myers@Sun.COM     ACPI_HANDLE             ObjHandle,
405*9980SDana.Myers@Sun.COM     UINT32                  NestingLevel,
406*9980SDana.Myers@Sun.COM     void                    *Context,
407*9980SDana.Myers@Sun.COM     void                    **ReturnValue)
408*9980SDana.Myers@Sun.COM {
409*9980SDana.Myers@Sun.COM     ACPI_NAMESPACE_NODE         *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
410*9980SDana.Myers@Sun.COM     UINT32                      *Count = (UINT32 *) Context;
411*9980SDana.Myers@Sun.COM     const ACPI_PREDEFINED_INFO  *Predefined;
412*9980SDana.Myers@Sun.COM     const ACPI_PREDEFINED_INFO  *Package = NULL;
413*9980SDana.Myers@Sun.COM     char                        *Pathname;
414*9980SDana.Myers@Sun.COM 
415*9980SDana.Myers@Sun.COM 
416*9980SDana.Myers@Sun.COM     Predefined = AcpiNsCheckForPredefinedName (Node);
417*9980SDana.Myers@Sun.COM     if (!Predefined)
418*9980SDana.Myers@Sun.COM     {
419*9980SDana.Myers@Sun.COM         return (AE_OK);
420*9980SDana.Myers@Sun.COM     }
421*9980SDana.Myers@Sun.COM 
422*9980SDana.Myers@Sun.COM     Pathname = AcpiNsGetExternalPathname (Node);
423*9980SDana.Myers@Sun.COM     if (!Pathname)
424*9980SDana.Myers@Sun.COM     {
425*9980SDana.Myers@Sun.COM         return (AE_OK);
426*9980SDana.Myers@Sun.COM     }
427*9980SDana.Myers@Sun.COM 
428*9980SDana.Myers@Sun.COM     /* If method returns a package, the info is in the next table entry */
429*9980SDana.Myers@Sun.COM 
430*9980SDana.Myers@Sun.COM     if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE)
431*9980SDana.Myers@Sun.COM     {
432*9980SDana.Myers@Sun.COM         Package = Predefined + 1;
433*9980SDana.Myers@Sun.COM     }
434*9980SDana.Myers@Sun.COM 
435*9980SDana.Myers@Sun.COM     AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname,
436*9980SDana.Myers@Sun.COM         Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes);
437*9980SDana.Myers@Sun.COM 
438*9980SDana.Myers@Sun.COM     if (Package)
439*9980SDana.Myers@Sun.COM     {
440*9980SDana.Myers@Sun.COM         AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X",
441*9980SDana.Myers@Sun.COM             Package->RetInfo.Type, Package->RetInfo.ObjectType1,
442*9980SDana.Myers@Sun.COM             Package->RetInfo.Count1);
443*9980SDana.Myers@Sun.COM     }
444*9980SDana.Myers@Sun.COM 
445*9980SDana.Myers@Sun.COM     AcpiOsPrintf("\n");
446*9980SDana.Myers@Sun.COM 
447*9980SDana.Myers@Sun.COM     AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined);
448*9980SDana.Myers@Sun.COM     ACPI_FREE (Pathname);
449*9980SDana.Myers@Sun.COM     (*Count)++;
450*9980SDana.Myers@Sun.COM 
451*9980SDana.Myers@Sun.COM     return (AE_OK);
452*9980SDana.Myers@Sun.COM }
453*9980SDana.Myers@Sun.COM 
454*9980SDana.Myers@Sun.COM 
455*9980SDana.Myers@Sun.COM /*******************************************************************************
456*9980SDana.Myers@Sun.COM  *
457*9980SDana.Myers@Sun.COM  * FUNCTION:    AcpiDbCheckPredefinedNames
458*9980SDana.Myers@Sun.COM  *
459*9980SDana.Myers@Sun.COM  * PARAMETERS:  None
460*9980SDana.Myers@Sun.COM  *
461*9980SDana.Myers@Sun.COM  * RETURN:      None
462*9980SDana.Myers@Sun.COM  *
463*9980SDana.Myers@Sun.COM  * DESCRIPTION: Validate all predefined names in the namespace
464*9980SDana.Myers@Sun.COM  *
465*9980SDana.Myers@Sun.COM  ******************************************************************************/
466*9980SDana.Myers@Sun.COM 
467*9980SDana.Myers@Sun.COM void
468*9980SDana.Myers@Sun.COM AcpiDbCheckPredefinedNames (
469*9980SDana.Myers@Sun.COM     void)
470*9980SDana.Myers@Sun.COM {
471*9980SDana.Myers@Sun.COM     UINT32                  Count = 0;
472*9980SDana.Myers@Sun.COM 
473*9980SDana.Myers@Sun.COM 
474*9980SDana.Myers@Sun.COM     /* Search all nodes in namespace */
475*9980SDana.Myers@Sun.COM 
476*9980SDana.Myers@Sun.COM     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
477*9980SDana.Myers@Sun.COM                 AcpiDbWalkForPredefinedNames, (void *) &Count, NULL);
478*9980SDana.Myers@Sun.COM 
479*9980SDana.Myers@Sun.COM     AcpiOsPrintf ("Found %d predefined names in the namespace\n", Count);
480*9980SDana.Myers@Sun.COM }
481*9980SDana.Myers@Sun.COM 
482*9980SDana.Myers@Sun.COM 
483*9980SDana.Myers@Sun.COM /*******************************************************************************
484*9980SDana.Myers@Sun.COM  *
485*9980SDana.Myers@Sun.COM  * FUNCTION:    AcpiDbWalkForExecute
486*9980SDana.Myers@Sun.COM  *
487*9980SDana.Myers@Sun.COM  * PARAMETERS:  Callback from WalkNamespace
488*9980SDana.Myers@Sun.COM  *
489*9980SDana.Myers@Sun.COM  * RETURN:      Status
490*9980SDana.Myers@Sun.COM  *
491*9980SDana.Myers@Sun.COM  * DESCRIPTION: Batch execution module. Currently only executes predefined
492*9980SDana.Myers@Sun.COM  *              ACPI names.
493*9980SDana.Myers@Sun.COM  *
494*9980SDana.Myers@Sun.COM  ******************************************************************************/
495*9980SDana.Myers@Sun.COM 
496*9980SDana.Myers@Sun.COM static ACPI_STATUS
497*9980SDana.Myers@Sun.COM AcpiDbWalkForExecute (
498*9980SDana.Myers@Sun.COM     ACPI_HANDLE             ObjHandle,
499*9980SDana.Myers@Sun.COM     UINT32                  NestingLevel,
500*9980SDana.Myers@Sun.COM     void                    *Context,
501*9980SDana.Myers@Sun.COM     void                    **ReturnValue)
502*9980SDana.Myers@Sun.COM {
503*9980SDana.Myers@Sun.COM     ACPI_NAMESPACE_NODE         *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
504*9980SDana.Myers@Sun.COM     UINT32                      *Count = (UINT32 *) Context;
505*9980SDana.Myers@Sun.COM     const ACPI_PREDEFINED_INFO  *Predefined;
506*9980SDana.Myers@Sun.COM     ACPI_BUFFER                 ReturnObj;
507*9980SDana.Myers@Sun.COM     ACPI_STATUS                 Status;
508*9980SDana.Myers@Sun.COM     char                        *Pathname;
509*9980SDana.Myers@Sun.COM     ACPI_BUFFER             Buffer;
510*9980SDana.Myers@Sun.COM     UINT32                  i;
511*9980SDana.Myers@Sun.COM     ACPI_DEVICE_INFO        *ObjInfo;
512*9980SDana.Myers@Sun.COM     ACPI_OBJECT_LIST        ParamObjects;
513*9980SDana.Myers@Sun.COM     ACPI_OBJECT             Params[ACPI_METHOD_NUM_ARGS];
514*9980SDana.Myers@Sun.COM 
515*9980SDana.Myers@Sun.COM 
516*9980SDana.Myers@Sun.COM     Predefined = AcpiNsCheckForPredefinedName (Node);
517*9980SDana.Myers@Sun.COM     if (!Predefined)
518*9980SDana.Myers@Sun.COM     {
519*9980SDana.Myers@Sun.COM         return (AE_OK);
520*9980SDana.Myers@Sun.COM     }
521*9980SDana.Myers@Sun.COM 
522*9980SDana.Myers@Sun.COM     if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
523*9980SDana.Myers@Sun.COM     {
524*9980SDana.Myers@Sun.COM         return (AE_OK);
525*9980SDana.Myers@Sun.COM     }
526*9980SDana.Myers@Sun.COM 
527*9980SDana.Myers@Sun.COM     Pathname = AcpiNsGetExternalPathname (Node);
528*9980SDana.Myers@Sun.COM     if (!Pathname)
529*9980SDana.Myers@Sun.COM     {
530*9980SDana.Myers@Sun.COM         return (AE_OK);
531*9980SDana.Myers@Sun.COM     }
532*9980SDana.Myers@Sun.COM 
533*9980SDana.Myers@Sun.COM     /* Get the object info for number of method parameters */
534*9980SDana.Myers@Sun.COM 
535*9980SDana.Myers@Sun.COM     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
536*9980SDana.Myers@Sun.COM     Status = AcpiGetObjectInfo (ObjHandle, &Buffer);
537*9980SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
538*9980SDana.Myers@Sun.COM     {
539*9980SDana.Myers@Sun.COM         return (Status);
540*9980SDana.Myers@Sun.COM     }
541*9980SDana.Myers@Sun.COM 
542*9980SDana.Myers@Sun.COM     ParamObjects.Pointer = NULL;
543*9980SDana.Myers@Sun.COM     ParamObjects.Count   = 0;
544*9980SDana.Myers@Sun.COM 
545*9980SDana.Myers@Sun.COM     ObjInfo = Buffer.Pointer;
546*9980SDana.Myers@Sun.COM     if (ObjInfo->Type == ACPI_TYPE_METHOD)
547*9980SDana.Myers@Sun.COM     {
548*9980SDana.Myers@Sun.COM 
549*9980SDana.Myers@Sun.COM         /* Setup default parameters */
550*9980SDana.Myers@Sun.COM 
551*9980SDana.Myers@Sun.COM         for (i = 0; i < ObjInfo->ParamCount; i++)
552*9980SDana.Myers@Sun.COM         {
553*9980SDana.Myers@Sun.COM             Params[i].Type           = ACPI_TYPE_INTEGER;
554*9980SDana.Myers@Sun.COM             Params[i].Integer.Value  = 1;
555*9980SDana.Myers@Sun.COM         }
556*9980SDana.Myers@Sun.COM 
557*9980SDana.Myers@Sun.COM         ParamObjects.Pointer     = Params;
558*9980SDana.Myers@Sun.COM         ParamObjects.Count       = ObjInfo->ParamCount;
559*9980SDana.Myers@Sun.COM     }
560*9980SDana.Myers@Sun.COM 
561*9980SDana.Myers@Sun.COM     ACPI_FREE (Buffer.Pointer);
562*9980SDana.Myers@Sun.COM 
563*9980SDana.Myers@Sun.COM     ReturnObj.Pointer = NULL;
564*9980SDana.Myers@Sun.COM     ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
565*9980SDana.Myers@Sun.COM 
566*9980SDana.Myers@Sun.COM 
567*9980SDana.Myers@Sun.COM     /* Do the actual method execution */
568*9980SDana.Myers@Sun.COM 
569*9980SDana.Myers@Sun.COM     AcpiGbl_MethodExecuting = TRUE;
570*9980SDana.Myers@Sun.COM 
571*9980SDana.Myers@Sun.COM     Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
572*9980SDana.Myers@Sun.COM 
573*9980SDana.Myers@Sun.COM     AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
574*9980SDana.Myers@Sun.COM     AcpiGbl_MethodExecuting = FALSE;
575*9980SDana.Myers@Sun.COM 
576*9980SDana.Myers@Sun.COM     ACPI_FREE (Pathname);
577*9980SDana.Myers@Sun.COM     (*Count)++;
578*9980SDana.Myers@Sun.COM 
579*9980SDana.Myers@Sun.COM     return (AE_OK);
580*9980SDana.Myers@Sun.COM }
581*9980SDana.Myers@Sun.COM 
582*9980SDana.Myers@Sun.COM 
583*9980SDana.Myers@Sun.COM /*******************************************************************************
584*9980SDana.Myers@Sun.COM  *
585*9980SDana.Myers@Sun.COM  * FUNCTION:    AcpiDbBatchExecute
586*9980SDana.Myers@Sun.COM  *
587*9980SDana.Myers@Sun.COM  * PARAMETERS:  None
588*9980SDana.Myers@Sun.COM  *
589*9980SDana.Myers@Sun.COM  * RETURN:      None
590*9980SDana.Myers@Sun.COM  *
591*9980SDana.Myers@Sun.COM  * DESCRIPTION: Namespace batch execution.
592*9980SDana.Myers@Sun.COM  *
593*9980SDana.Myers@Sun.COM  ******************************************************************************/
594*9980SDana.Myers@Sun.COM 
595*9980SDana.Myers@Sun.COM void
596*9980SDana.Myers@Sun.COM AcpiDbBatchExecute (
597*9980SDana.Myers@Sun.COM     void)
598*9980SDana.Myers@Sun.COM {
599*9980SDana.Myers@Sun.COM     UINT32                  Count = 0;
600*9980SDana.Myers@Sun.COM 
601*9980SDana.Myers@Sun.COM 
602*9980SDana.Myers@Sun.COM     /* Search all nodes in namespace */
603*9980SDana.Myers@Sun.COM 
604*9980SDana.Myers@Sun.COM     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
605*9980SDana.Myers@Sun.COM                 AcpiDbWalkForExecute, (void *) &Count, NULL);
606*9980SDana.Myers@Sun.COM 
607*9980SDana.Myers@Sun.COM     AcpiOsPrintf ("Executed %d predefined names in the namespace\n", Count);
608*9980SDana.Myers@Sun.COM }
609*9980SDana.Myers@Sun.COM 
610*9980SDana.Myers@Sun.COM 
611*9980SDana.Myers@Sun.COM /*******************************************************************************
612*9980SDana.Myers@Sun.COM  *
6133446Smrj  * FUNCTION:    AcpiDbDisplayLocks
6143446Smrj  *
6153446Smrj  * PARAMETERS:  None
6163446Smrj  *
6173446Smrj  * RETURN:      None
6183446Smrj  *
6193446Smrj  * DESCRIPTION: Display information about internal mutexes.
6203446Smrj  *
6213446Smrj  ******************************************************************************/
6223446Smrj 
6233446Smrj void
6243446Smrj AcpiDbDisplayLocks (
6253446Smrj     void)
6263446Smrj {
6273446Smrj     UINT32                  i;
6283446Smrj 
6293446Smrj 
6303446Smrj     for (i = 0; i < ACPI_MAX_MUTEX; i++)
6313446Smrj     {
6323446Smrj         AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
6333446Smrj             AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
6343446Smrj                 ? "Locked" : "Unlocked");
6353446Smrj     }
6363446Smrj }
6373446Smrj 
6383446Smrj 
6393446Smrj /*******************************************************************************
6403446Smrj  *
6413446Smrj  * FUNCTION:    AcpiDbDisplayTableInfo
6423446Smrj  *
6433446Smrj  * PARAMETERS:  TableArg        - String with name of table to be displayed
6443446Smrj  *
6453446Smrj  * RETURN:      None
6463446Smrj  *
6473446Smrj  * DESCRIPTION: Display information about loaded tables.  Current
6483446Smrj  *              implementation displays all loaded tables.
6493446Smrj  *
6503446Smrj  ******************************************************************************/
6513446Smrj 
6523446Smrj void
6533446Smrj AcpiDbDisplayTableInfo (
6543446Smrj     char                    *TableArg)
6553446Smrj {
6563446Smrj     UINT32                  i;
6573446Smrj     ACPI_TABLE_DESC         *TableDesc;
658*9980SDana.Myers@Sun.COM     ACPI_STATUS             Status;
6593446Smrj 
6603446Smrj 
6617851SDana.Myers@Sun.COM     /* Walk the entire root table list */
6627851SDana.Myers@Sun.COM 
6637851SDana.Myers@Sun.COM     for (i = 0; i < AcpiGbl_RootTableList.Count; i++)
6643446Smrj     {
6657851SDana.Myers@Sun.COM         TableDesc = &AcpiGbl_RootTableList.Tables[i];
6667851SDana.Myers@Sun.COM         AcpiOsPrintf ("%d ", i);
6677851SDana.Myers@Sun.COM 
6687851SDana.Myers@Sun.COM         /* Make sure that the table is mapped */
6697851SDana.Myers@Sun.COM 
670*9980SDana.Myers@Sun.COM         Status = AcpiTbVerifyTable (TableDesc);
671*9980SDana.Myers@Sun.COM         if (ACPI_FAILURE (Status))
672*9980SDana.Myers@Sun.COM         {
673*9980SDana.Myers@Sun.COM             return;
674*9980SDana.Myers@Sun.COM         }
6753446Smrj 
6767851SDana.Myers@Sun.COM         /* Dump the table header */
6773446Smrj 
6787851SDana.Myers@Sun.COM         if (TableDesc->Pointer)
6797851SDana.Myers@Sun.COM         {
6807851SDana.Myers@Sun.COM             AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
6817851SDana.Myers@Sun.COM         }
6827851SDana.Myers@Sun.COM         else
6837851SDana.Myers@Sun.COM         {
6847851SDana.Myers@Sun.COM             /* If the pointer is null, the table has been unloaded */
6857851SDana.Myers@Sun.COM 
6867851SDana.Myers@Sun.COM             ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
6877851SDana.Myers@Sun.COM                 TableDesc->Signature.Ascii));
6883446Smrj         }
6893446Smrj     }
6903446Smrj }
6913446Smrj 
6923446Smrj 
6933446Smrj /*******************************************************************************
6943446Smrj  *
6953446Smrj  * FUNCTION:    AcpiDbUnloadAcpiTable
6963446Smrj  *
6973446Smrj  * PARAMETERS:  TableArg        - Name of the table to be unloaded
6983446Smrj  *              InstanceArg     - Which instance of the table to unload (if
6993446Smrj  *                                there are multiple tables of the same type)
7003446Smrj  *
7013446Smrj  * RETURN:      Nonde
7023446Smrj  *
7033446Smrj  * DESCRIPTION: Unload an ACPI table.
7043446Smrj  *              Instance is not implemented
7053446Smrj  *
7063446Smrj  ******************************************************************************/
7073446Smrj 
7083446Smrj void
7093446Smrj AcpiDbUnloadAcpiTable (
7103446Smrj     char                    *TableArg,
7113446Smrj     char                    *InstanceArg)
7123446Smrj {
7137851SDana.Myers@Sun.COM /* TBD: Need to reimplement for new data structures */
7147851SDana.Myers@Sun.COM 
7157851SDana.Myers@Sun.COM #if 0
7163446Smrj     UINT32                  i;
7173446Smrj     ACPI_STATUS             Status;
7183446Smrj 
7193446Smrj 
7203446Smrj     /* Search all tables for the target type */
7213446Smrj 
7223446Smrj     for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
7233446Smrj     {
7243446Smrj         if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature,
7253446Smrj                 AcpiGbl_TableData[i].SigLength))
7263446Smrj         {
7273446Smrj             /* Found the table, unload it */
7283446Smrj 
7293446Smrj             Status = AcpiUnloadTable (i);
7303446Smrj             if (ACPI_SUCCESS (Status))
7313446Smrj             {
7323446Smrj                 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
7333446Smrj             }
7343446Smrj             else
7353446Smrj             {
7363446Smrj                 AcpiOsPrintf ("%s, while unloading [%s]\n",
7373446Smrj                     AcpiFormatException (Status), TableArg);
7383446Smrj             }
7393446Smrj 
7403446Smrj             return;
7413446Smrj         }
7423446Smrj     }
7433446Smrj 
7443446Smrj     AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
7457851SDana.Myers@Sun.COM #endif
7463446Smrj }
7473446Smrj 
7483446Smrj 
7493446Smrj /*******************************************************************************
7503446Smrj  *
7513446Smrj  * FUNCTION:    AcpiDbSetMethodBreakpoint
7523446Smrj  *
7533446Smrj  * PARAMETERS:  Location            - AML offset of breakpoint
7543446Smrj  *              WalkState           - Current walk info
7553446Smrj  *              Op                  - Current Op (from parse walk)
7563446Smrj  *
7573446Smrj  * RETURN:      None
7583446Smrj  *
7593446Smrj  * DESCRIPTION: Set a breakpoint in a control method at the specified
7603446Smrj  *              AML offset
7613446Smrj  *
7623446Smrj  ******************************************************************************/
7633446Smrj 
7643446Smrj void
7653446Smrj AcpiDbSetMethodBreakpoint (
7663446Smrj     char                    *Location,
7673446Smrj     ACPI_WALK_STATE         *WalkState,
7683446Smrj     ACPI_PARSE_OBJECT       *Op)
7693446Smrj {
7703446Smrj     UINT32                  Address;
7713446Smrj 
7723446Smrj 
7733446Smrj     if (!Op)
7743446Smrj     {
7753446Smrj         AcpiOsPrintf ("There is no method currently executing\n");
7763446Smrj         return;
7773446Smrj     }
7783446Smrj 
7793446Smrj     /* Get and verify the breakpoint address */
7803446Smrj 
7813446Smrj     Address = ACPI_STRTOUL (Location, NULL, 16);
7823446Smrj     if (Address <= Op->Common.AmlOffset)
7833446Smrj     {
7843446Smrj         AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
7853446Smrj             Address, Op->Common.AmlOffset);
7863446Smrj     }
7873446Smrj 
7883446Smrj     /* Save breakpoint in current walk */
7893446Smrj 
7903446Smrj     WalkState->UserBreakpoint = Address;
7913446Smrj     AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
7923446Smrj }
7933446Smrj 
7943446Smrj 
7953446Smrj /*******************************************************************************
7963446Smrj  *
7973446Smrj  * FUNCTION:    AcpiDbSetMethodCallBreakpoint
7983446Smrj  *
7993446Smrj  * PARAMETERS:  Op                  - Current Op (from parse walk)
8003446Smrj  *
8013446Smrj  * RETURN:      None
8023446Smrj  *
8033446Smrj  * DESCRIPTION: Set a breakpoint in a control method at the specified
8043446Smrj  *              AML offset
8053446Smrj  *
8063446Smrj  ******************************************************************************/
8073446Smrj 
8083446Smrj void
8093446Smrj AcpiDbSetMethodCallBreakpoint (
8103446Smrj     ACPI_PARSE_OBJECT       *Op)
8113446Smrj {
8123446Smrj 
8133446Smrj 
8143446Smrj     if (!Op)
8153446Smrj     {
8163446Smrj         AcpiOsPrintf ("There is no method currently executing\n");
8173446Smrj         return;
8183446Smrj     }
8193446Smrj 
8203446Smrj     AcpiGbl_StepToNextCall = TRUE;
8213446Smrj }
8223446Smrj 
8233446Smrj 
8243446Smrj /*******************************************************************************
8253446Smrj  *
8263446Smrj  * FUNCTION:    AcpiDbDisassembleAml
8273446Smrj  *
8283446Smrj  * PARAMETERS:  Statements          - Number of statements to disassemble
8293446Smrj  *              Op                  - Current Op (from parse walk)
8303446Smrj  *
8313446Smrj  * RETURN:      None
8323446Smrj  *
8333446Smrj  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
8343446Smrj  *              of statements specified.
8353446Smrj  *
8363446Smrj  ******************************************************************************/
8373446Smrj 
8383446Smrj void
8393446Smrj AcpiDbDisassembleAml (
8403446Smrj     char                    *Statements,
8413446Smrj     ACPI_PARSE_OBJECT       *Op)
8423446Smrj {
8433446Smrj     UINT32                  NumStatements = 8;
8443446Smrj 
8453446Smrj 
8463446Smrj     if (!Op)
8473446Smrj     {
8483446Smrj         AcpiOsPrintf ("There is no method currently executing\n");
8493446Smrj         return;
8503446Smrj     }
8513446Smrj 
8523446Smrj     if (Statements)
8533446Smrj     {
8543446Smrj         NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
8553446Smrj     }
8563446Smrj 
8573446Smrj     AcpiDmDisassemble (NULL, Op, NumStatements);
8583446Smrj }
8593446Smrj 
8603446Smrj 
8613446Smrj /*******************************************************************************
8623446Smrj  *
8633446Smrj  * FUNCTION:    AcpiDbDisassembleMethod
8643446Smrj  *
8653446Smrj  * PARAMETERS:  Name            - Name of control method
8663446Smrj  *
8673446Smrj  * RETURN:      None
8683446Smrj  *
8693446Smrj  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
8703446Smrj  *              of statements specified.
8713446Smrj  *
8723446Smrj  ******************************************************************************/
8733446Smrj 
8743446Smrj ACPI_STATUS
8753446Smrj AcpiDbDisassembleMethod (
8763446Smrj     char                    *Name)
8773446Smrj {
8783446Smrj     ACPI_STATUS             Status;
8793446Smrj     ACPI_PARSE_OBJECT       *Op;
8803446Smrj     ACPI_WALK_STATE         *WalkState;
8813446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
8823446Smrj     ACPI_NAMESPACE_NODE     *Method;
8833446Smrj 
8843446Smrj 
8853446Smrj     Method = AcpiDbConvertToNode (Name);
8863446Smrj     if (!Method)
8873446Smrj     {
8883446Smrj         return (AE_BAD_PARAMETER);
8893446Smrj     }
8903446Smrj 
8913446Smrj     ObjDesc = Method->Object;
8923446Smrj 
8933446Smrj     Op = AcpiPsCreateScopeOp ();
8943446Smrj     if (!Op)
8953446Smrj     {
8963446Smrj         return (AE_NO_MEMORY);
8973446Smrj     }
8983446Smrj 
8993446Smrj     /* Create and initialize a new walk state */
9003446Smrj 
9013446Smrj     WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
9023446Smrj     if (!WalkState)
9033446Smrj     {
9043446Smrj         return (AE_NO_MEMORY);
9053446Smrj     }
9063446Smrj 
9073446Smrj     Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
9083446Smrj                     ObjDesc->Method.AmlStart,
9097851SDana.Myers@Sun.COM                     ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
9103446Smrj     if (ACPI_FAILURE (Status))
9113446Smrj     {
9123446Smrj         return (Status);
9133446Smrj     }
9143446Smrj 
9153446Smrj     /* Parse the AML */
9163446Smrj 
9173446Smrj     WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
9183446Smrj     WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
9193446Smrj     Status = AcpiPsParseAml (WalkState);
9203446Smrj 
9213446Smrj     AcpiDmDisassemble (NULL, Op, 0);
9223446Smrj     AcpiPsDeleteParseTree (Op);
9233446Smrj     return (AE_OK);
9243446Smrj }
9253446Smrj 
9263446Smrj 
9273446Smrj /*******************************************************************************
9283446Smrj  *
9293446Smrj  * FUNCTION:    AcpiDbDumpNamespace
9303446Smrj  *
9313446Smrj  * PARAMETERS:  StartArg        - Node to begin namespace dump
9323446Smrj  *              DepthArg        - Maximum tree depth to be dumped
9333446Smrj  *
9343446Smrj  * RETURN:      None
9353446Smrj  *
9363446Smrj  * DESCRIPTION: Dump entire namespace or a subtree.  Each node is displayed
9373446Smrj  *              with type and other information.
9383446Smrj  *
9393446Smrj  ******************************************************************************/
9403446Smrj 
9413446Smrj void
9423446Smrj AcpiDbDumpNamespace (
9433446Smrj     char                    *StartArg,
9443446Smrj     char                    *DepthArg)
9453446Smrj {
9463446Smrj     ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
9473446Smrj     UINT32                  MaxDepth = ACPI_UINT32_MAX;
9483446Smrj 
9493446Smrj 
9503446Smrj     /* No argument given, just start at the root and dump entire namespace */
9513446Smrj 
9523446Smrj     if (StartArg)
9533446Smrj     {
9543446Smrj         SubtreeEntry = AcpiDbConvertToNode (StartArg);
9553446Smrj         if (!SubtreeEntry)
9563446Smrj         {
9573446Smrj             return;
9583446Smrj         }
9593446Smrj 
9603446Smrj         /* Now we can check for the depth argument */
9613446Smrj 
9623446Smrj         if (DepthArg)
9633446Smrj         {
9643446Smrj             MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
9653446Smrj         }
9663446Smrj     }
9673446Smrj 
9683446Smrj     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
9693446Smrj     AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
9703446Smrj         ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
9713446Smrj 
9723446Smrj     /* Display the subtree */
9733446Smrj 
9743446Smrj     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
9753446Smrj     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
9763446Smrj         ACPI_OWNER_ID_MAX, SubtreeEntry);
9773446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
9783446Smrj }
9793446Smrj 
9803446Smrj 
9813446Smrj /*******************************************************************************
9823446Smrj  *
9833446Smrj  * FUNCTION:    AcpiDbDumpNamespaceByOwner
9843446Smrj  *
9853446Smrj  * PARAMETERS:  OwnerArg        - Owner ID whose nodes will be displayed
9863446Smrj  *              DepthArg        - Maximum tree depth to be dumped
9873446Smrj  *
9883446Smrj  * RETURN:      None
9893446Smrj  *
9903446Smrj  * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
9913446Smrj  *
9923446Smrj  ******************************************************************************/
9933446Smrj 
9943446Smrj void
9953446Smrj AcpiDbDumpNamespaceByOwner (
9963446Smrj     char                    *OwnerArg,
9973446Smrj     char                    *DepthArg)
9983446Smrj {
9993446Smrj     ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
10003446Smrj     UINT32                  MaxDepth = ACPI_UINT32_MAX;
10013446Smrj     ACPI_OWNER_ID           OwnerId;
10023446Smrj 
10033446Smrj 
10043446Smrj     OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
10053446Smrj 
10063446Smrj     /* Now we can check for the depth argument */
10073446Smrj 
10083446Smrj     if (DepthArg)
10093446Smrj     {
10103446Smrj         MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
10113446Smrj     }
10123446Smrj 
10133446Smrj     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
10143446Smrj     AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
10153446Smrj 
10163446Smrj     /* Display the subtree */
10173446Smrj 
10183446Smrj     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
10193446Smrj     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId,
10203446Smrj         SubtreeEntry);
10213446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
10223446Smrj }
10233446Smrj 
10243446Smrj 
10253446Smrj /*******************************************************************************
10263446Smrj  *
10273446Smrj  * FUNCTION:    AcpiDbSendNotify
10283446Smrj  *
10293446Smrj  * PARAMETERS:  Name            - Name of ACPI object to send the notify to
10303446Smrj  *              Value           - Value of the notify to send.
10313446Smrj  *
10323446Smrj  * RETURN:      None
10333446Smrj  *
10343446Smrj  * DESCRIPTION: Send an ACPI notification.  The value specified is sent to the
10353446Smrj  *              named object as an ACPI notify.
10363446Smrj  *
10373446Smrj  ******************************************************************************/
10383446Smrj 
10393446Smrj void
10403446Smrj AcpiDbSendNotify (
10413446Smrj     char                    *Name,
10423446Smrj     UINT32                  Value)
10433446Smrj {
10443446Smrj     ACPI_NAMESPACE_NODE     *Node;
10453446Smrj     ACPI_STATUS             Status;
10463446Smrj 
10473446Smrj 
10483446Smrj     /* Translate name to an Named object */
10493446Smrj 
10503446Smrj     Node = AcpiDbConvertToNode (Name);
10513446Smrj     if (!Node)
10523446Smrj     {
10533446Smrj         return;
10543446Smrj     }
10553446Smrj 
10563446Smrj     /* Decode Named object type */
10573446Smrj 
10583446Smrj     switch (Node->Type)
10593446Smrj     {
10603446Smrj     case ACPI_TYPE_DEVICE:
10613446Smrj     case ACPI_TYPE_THERMAL:
10623446Smrj 
10633446Smrj          /* Send the notify */
10643446Smrj 
10653446Smrj         Status = AcpiEvQueueNotifyRequest (Node, Value);
10663446Smrj         if (ACPI_FAILURE (Status))
10673446Smrj         {
10683446Smrj             AcpiOsPrintf ("Could not queue notify\n");
10693446Smrj         }
10703446Smrj         break;
10713446Smrj 
10723446Smrj     default:
10733446Smrj         AcpiOsPrintf ("Named object is not a device or a thermal object\n");
10743446Smrj         break;
10753446Smrj     }
10763446Smrj }
10773446Smrj 
10783446Smrj 
10793446Smrj /*******************************************************************************
10803446Smrj  *
10813446Smrj  * FUNCTION:    AcpiDbSetMethodData
10823446Smrj  *
10833446Smrj  * PARAMETERS:  TypeArg         - L for local, A for argument
10843446Smrj  *              IndexArg        - which one
10853446Smrj  *              ValueArg        - Value to set.
10863446Smrj  *
10873446Smrj  * RETURN:      None
10883446Smrj  *
10893446Smrj  * DESCRIPTION: Set a local or argument for the running control method.
10903446Smrj  *              NOTE: only object supported is Number.
10913446Smrj  *
10923446Smrj  ******************************************************************************/
10933446Smrj 
10943446Smrj void
10953446Smrj AcpiDbSetMethodData (
10963446Smrj     char                    *TypeArg,
10973446Smrj     char                    *IndexArg,
10983446Smrj     char                    *ValueArg)
10993446Smrj {
11003446Smrj     char                    Type;
11013446Smrj     UINT32                  Index;
11023446Smrj     UINT32                  Value;
11033446Smrj     ACPI_WALK_STATE         *WalkState;
11043446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
11053446Smrj     ACPI_STATUS             Status;
11063446Smrj     ACPI_NAMESPACE_NODE     *Node;
11073446Smrj 
11083446Smrj 
11093446Smrj     /* Validate TypeArg */
11103446Smrj 
11113446Smrj     AcpiUtStrupr (TypeArg);
11123446Smrj     Type = TypeArg[0];
11133446Smrj     if ((Type != 'L') &&
11143446Smrj         (Type != 'A') &&
11153446Smrj         (Type != 'N'))
11163446Smrj     {
11173446Smrj         AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
11183446Smrj         return;
11193446Smrj     }
11203446Smrj 
11213446Smrj     Value = ACPI_STRTOUL (ValueArg, NULL, 16);
11223446Smrj 
11233446Smrj     if (Type == 'N')
11243446Smrj     {
11253446Smrj         Node = AcpiDbConvertToNode (IndexArg);
11263446Smrj         if (Node->Type != ACPI_TYPE_INTEGER)
11273446Smrj         {
11283446Smrj             AcpiOsPrintf ("Can only set Integer nodes\n");
11293446Smrj             return;
11303446Smrj         }
11313446Smrj         ObjDesc = Node->Object;
11323446Smrj         ObjDesc->Integer.Value = Value;
11333446Smrj         return;
11343446Smrj     }
11353446Smrj 
11363446Smrj     /* Get the index and value */
11373446Smrj 
11383446Smrj     Index = ACPI_STRTOUL (IndexArg, NULL, 16);
11393446Smrj 
11403446Smrj     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
11413446Smrj     if (!WalkState)
11423446Smrj     {
11433446Smrj         AcpiOsPrintf ("There is no method currently executing\n");
11443446Smrj         return;
11453446Smrj     }
11463446Smrj 
11473446Smrj     /* Create and initialize the new object */
11483446Smrj 
11493446Smrj     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
11503446Smrj     if (!ObjDesc)
11513446Smrj     {
11523446Smrj         AcpiOsPrintf ("Could not create an internal object\n");
11533446Smrj         return;
11543446Smrj     }
11553446Smrj 
11563446Smrj     ObjDesc->Integer.Value = Value;
11573446Smrj 
11583446Smrj     /* Store the new object into the target */
11593446Smrj 
11603446Smrj     switch (Type)
11613446Smrj     {
11623446Smrj     case 'A':
11633446Smrj 
11643446Smrj         /* Set a method argument */
11653446Smrj 
11663446Smrj         if (Index > ACPI_METHOD_MAX_ARG)
11673446Smrj         {
11683446Smrj             AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
11693446Smrj             goto Cleanup;
11703446Smrj         }
11713446Smrj 
11727851SDana.Myers@Sun.COM         Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc,
11733446Smrj                     WalkState);
11743446Smrj         if (ACPI_FAILURE (Status))
11753446Smrj         {
11763446Smrj             goto Cleanup;
11773446Smrj         }
11783446Smrj 
11793446Smrj         ObjDesc = WalkState->Arguments[Index].Object;
11803446Smrj 
11813446Smrj         AcpiOsPrintf ("Arg%d: ", Index);
11823446Smrj         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
11833446Smrj         break;
11843446Smrj 
11853446Smrj     case 'L':
11863446Smrj 
11873446Smrj         /* Set a method local */
11883446Smrj 
11893446Smrj         if (Index > ACPI_METHOD_MAX_LOCAL)
11903446Smrj         {
11913446Smrj             AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
11923446Smrj             goto Cleanup;
11933446Smrj         }
11943446Smrj 
11957851SDana.Myers@Sun.COM         Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc,
11963446Smrj                     WalkState);
11973446Smrj         if (ACPI_FAILURE (Status))
11983446Smrj         {
11993446Smrj             goto Cleanup;
12003446Smrj         }
12013446Smrj 
12023446Smrj         ObjDesc = WalkState->LocalVariables[Index].Object;
12033446Smrj 
12043446Smrj         AcpiOsPrintf ("Local%d: ", Index);
12053446Smrj         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
12063446Smrj         break;
12073446Smrj 
12083446Smrj     default:
12093446Smrj         break;
12103446Smrj     }
12113446Smrj 
12123446Smrj Cleanup:
12133446Smrj     AcpiUtRemoveReference (ObjDesc);
12143446Smrj }
12153446Smrj 
12163446Smrj 
12173446Smrj /*******************************************************************************
12183446Smrj  *
12193446Smrj  * FUNCTION:    AcpiDbWalkForSpecificObjects
12203446Smrj  *
12213446Smrj  * PARAMETERS:  Callback from WalkNamespace
12223446Smrj  *
12233446Smrj  * RETURN:      Status
12243446Smrj  *
12253446Smrj  * DESCRIPTION: Display short info about objects in the namespace
12263446Smrj  *
12273446Smrj  ******************************************************************************/
12283446Smrj 
12293446Smrj static ACPI_STATUS
12303446Smrj AcpiDbWalkForSpecificObjects (
12313446Smrj     ACPI_HANDLE             ObjHandle,
12323446Smrj     UINT32                  NestingLevel,
12333446Smrj     void                    *Context,
12343446Smrj     void                    **ReturnValue)
12353446Smrj {
12363446Smrj     ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
12373446Smrj     ACPI_BUFFER             Buffer;
12383446Smrj     ACPI_STATUS             Status;
12393446Smrj 
12403446Smrj 
12413446Smrj     Info->Count++;
12423446Smrj 
12433446Smrj     /* Get and display the full pathname to this object */
12443446Smrj 
12453446Smrj     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
12463446Smrj     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
12473446Smrj     if (ACPI_FAILURE (Status))
12483446Smrj     {
12493446Smrj         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
12503446Smrj         return (AE_OK);
12513446Smrj     }
12523446Smrj 
12533446Smrj     AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
12543446Smrj     ACPI_FREE (Buffer.Pointer);
12553446Smrj 
12563446Smrj     /* Dump short info about the object */
12573446Smrj 
12583446Smrj     (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
12593446Smrj     return (AE_OK);
12603446Smrj }
12613446Smrj 
12623446Smrj 
12633446Smrj /*******************************************************************************
12643446Smrj  *
12653446Smrj  * FUNCTION:    AcpiDbDisplayObjects
12663446Smrj  *
12673446Smrj  * PARAMETERS:  ObjTypeArg          - Type of object to display
12683446Smrj  *              DisplayCountArg     - Max depth to display
12693446Smrj  *
12703446Smrj  * RETURN:      None
12713446Smrj  *
12723446Smrj  * DESCRIPTION: Display objects in the namespace of the requested type
12733446Smrj  *
12743446Smrj  ******************************************************************************/
12753446Smrj 
12763446Smrj ACPI_STATUS
12773446Smrj AcpiDbDisplayObjects (
12783446Smrj     char                    *ObjTypeArg,
12793446Smrj     char                    *DisplayCountArg)
12803446Smrj {
12813446Smrj     ACPI_WALK_INFO          Info;
12823446Smrj     ACPI_OBJECT_TYPE        Type;
12833446Smrj 
12843446Smrj 
12853446Smrj     /* Get the object type */
12863446Smrj 
12873446Smrj     Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
12883446Smrj     if (Type == ACPI_TYPE_NOT_FOUND)
12893446Smrj     {
12903446Smrj         AcpiOsPrintf ("Invalid or unsupported argument\n");
12913446Smrj         return (AE_OK);
12923446Smrj     }
12933446Smrj 
12943446Smrj     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
12953446Smrj     AcpiOsPrintf (
12963446Smrj         "Objects of type [%s] defined in the current ACPI Namespace:\n",
12973446Smrj         AcpiUtGetTypeName (Type));
12983446Smrj 
12993446Smrj     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
13003446Smrj 
13013446Smrj     Info.Count = 0;
13023446Smrj     Info.OwnerId = ACPI_OWNER_ID_MAX;
13033446Smrj     Info.DebugLevel = ACPI_UINT32_MAX;
13043446Smrj     Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
13053446Smrj 
13063446Smrj     /* Walk the namespace from the root */
13073446Smrj 
13083446Smrj     (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
13093446Smrj                 AcpiDbWalkForSpecificObjects, (void *) &Info, NULL);
13103446Smrj 
13113446Smrj     AcpiOsPrintf (
13123446Smrj         "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
13133446Smrj         Info.Count, AcpiUtGetTypeName (Type));
13143446Smrj 
13153446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
13163446Smrj     return (AE_OK);
13173446Smrj }
13183446Smrj 
13193446Smrj 
13203446Smrj /*******************************************************************************
13213446Smrj  *
13223446Smrj  * FUNCTION:    AcpiDbWalkAndMatchName
13233446Smrj  *
13243446Smrj  * PARAMETERS:  Callback from WalkNamespace
13253446Smrj  *
13263446Smrj  * RETURN:      Status
13273446Smrj  *
13283446Smrj  * DESCRIPTION: Find a particular name/names within the namespace.  Wildcards
13293446Smrj  *              are supported -- '?' matches any character.
13303446Smrj  *
13313446Smrj  ******************************************************************************/
13323446Smrj 
13333446Smrj static ACPI_STATUS
13343446Smrj AcpiDbWalkAndMatchName (
13353446Smrj     ACPI_HANDLE             ObjHandle,
13363446Smrj     UINT32                  NestingLevel,
13373446Smrj     void                    *Context,
13383446Smrj     void                    **ReturnValue)
13393446Smrj {
13403446Smrj     ACPI_STATUS             Status;
13413446Smrj     char                    *RequestedName = (char *) Context;
13423446Smrj     UINT32                  i;
13433446Smrj     ACPI_BUFFER             Buffer;
13443446Smrj     ACPI_WALK_INFO          Info;
13453446Smrj 
13463446Smrj 
13473446Smrj     /* Check for a name match */
13483446Smrj 
13493446Smrj     for (i = 0; i < 4; i++)
13503446Smrj     {
13513446Smrj         /* Wildcard support */
13523446Smrj 
13533446Smrj         if ((RequestedName[i] != '?') &&
13543446Smrj             (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
13553446Smrj         {
13563446Smrj             /* No match, just exit */
13573446Smrj 
13583446Smrj             return (AE_OK);
13593446Smrj         }
13603446Smrj     }
13613446Smrj 
13623446Smrj     /* Get the full pathname to this object */
13633446Smrj 
13643446Smrj     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
13653446Smrj     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
13663446Smrj     if (ACPI_FAILURE (Status))
13673446Smrj     {
13683446Smrj         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
13693446Smrj     }
13703446Smrj     else
13713446Smrj     {
13723446Smrj         Info.OwnerId = ACPI_OWNER_ID_MAX;
13733446Smrj         Info.DebugLevel = ACPI_UINT32_MAX;
13743446Smrj         Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
13753446Smrj 
13763446Smrj         AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
13773446Smrj         (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
13783446Smrj         ACPI_FREE (Buffer.Pointer);
13793446Smrj     }
13803446Smrj 
13813446Smrj     return (AE_OK);
13823446Smrj }
13833446Smrj 
13843446Smrj 
13853446Smrj /*******************************************************************************
13863446Smrj  *
13873446Smrj  * FUNCTION:    AcpiDbFindNameInNamespace
13883446Smrj  *
13893446Smrj  * PARAMETERS:  NameArg         - The 4-character ACPI name to find.
13903446Smrj  *                                wildcards are supported.
13913446Smrj  *
13923446Smrj  * RETURN:      None
13933446Smrj  *
13943446Smrj  * DESCRIPTION: Search the namespace for a given name (with wildcards)
13953446Smrj  *
13963446Smrj  ******************************************************************************/
13973446Smrj 
13983446Smrj ACPI_STATUS
13993446Smrj AcpiDbFindNameInNamespace (
14003446Smrj     char                    *NameArg)
14013446Smrj {
1402*9980SDana.Myers@Sun.COM     char                    AcpiName[5] = "____";
1403*9980SDana.Myers@Sun.COM     char                    *AcpiNamePtr = AcpiName;
1404*9980SDana.Myers@Sun.COM 
14053446Smrj 
14063446Smrj     if (ACPI_STRLEN (NameArg) > 4)
14073446Smrj     {
14083446Smrj         AcpiOsPrintf ("Name must be no longer than 4 characters\n");
14093446Smrj         return (AE_OK);
14103446Smrj     }
14113446Smrj 
1412*9980SDana.Myers@Sun.COM     /* Pad out name with underscores as necessary to create a 4-char name */
14133446Smrj 
14143446Smrj     AcpiUtStrupr (NameArg);
1415*9980SDana.Myers@Sun.COM     while (*NameArg)
1416*9980SDana.Myers@Sun.COM     {
1417*9980SDana.Myers@Sun.COM         *AcpiNamePtr = *NameArg;
1418*9980SDana.Myers@Sun.COM         AcpiNamePtr++;
1419*9980SDana.Myers@Sun.COM         NameArg++;
1420*9980SDana.Myers@Sun.COM     }
1421*9980SDana.Myers@Sun.COM 
1422*9980SDana.Myers@Sun.COM     /* Walk the namespace from the root */
1423*9980SDana.Myers@Sun.COM 
14243446Smrj     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1425*9980SDana.Myers@Sun.COM                         AcpiDbWalkAndMatchName, AcpiName, NULL);
14263446Smrj 
14273446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
14283446Smrj     return (AE_OK);
14293446Smrj }
14303446Smrj 
14313446Smrj 
14323446Smrj /*******************************************************************************
14333446Smrj  *
14343446Smrj  * FUNCTION:    AcpiDbSetScope
14353446Smrj  *
14363446Smrj  * PARAMETERS:  Name                - New scope path
14373446Smrj  *
14383446Smrj  * RETURN:      Status
14393446Smrj  *
14403446Smrj  * DESCRIPTION: Set the "current scope" as maintained by this utility.
14413446Smrj  *              The scope is used as a prefix to ACPI paths.
14423446Smrj  *
14433446Smrj  ******************************************************************************/
14443446Smrj 
14453446Smrj void
14463446Smrj AcpiDbSetScope (
14473446Smrj     char                    *Name)
14483446Smrj {
14493446Smrj     ACPI_STATUS             Status;
14503446Smrj     ACPI_NAMESPACE_NODE     *Node;
14513446Smrj 
14523446Smrj 
14533446Smrj     if (!Name || Name[0] == 0)
14543446Smrj     {
14553446Smrj         AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
14563446Smrj         return;
14573446Smrj     }
14583446Smrj 
14593446Smrj     AcpiDbPrepNamestring (Name);
14603446Smrj 
14613446Smrj     if (Name[0] == '\\')
14623446Smrj     {
14633446Smrj         /* Validate new scope from the root */
14643446Smrj 
14653446Smrj         Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
14663446Smrj                     &Node);
14673446Smrj         if (ACPI_FAILURE (Status))
14683446Smrj         {
14693446Smrj             goto ErrorExit;
14703446Smrj         }
14713446Smrj 
14723446Smrj         ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
14733446Smrj         ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
14743446Smrj     }
14753446Smrj     else
14763446Smrj     {
14773446Smrj         /* Validate new scope relative to old scope */
14783446Smrj 
14793446Smrj         Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
14803446Smrj                     &Node);
14813446Smrj         if (ACPI_FAILURE (Status))
14823446Smrj         {
14833446Smrj             goto ErrorExit;
14843446Smrj         }
14853446Smrj 
14863446Smrj         ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
14873446Smrj         ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
14883446Smrj     }
14893446Smrj 
14903446Smrj     AcpiGbl_DbScopeNode = Node;
14913446Smrj     AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
14923446Smrj     return;
14933446Smrj 
14943446Smrj ErrorExit:
14953446Smrj 
14963446Smrj     AcpiOsPrintf ("Could not attach scope: %s, %s\n",
14973446Smrj         Name, AcpiFormatException (Status));
14983446Smrj }
14993446Smrj 
15003446Smrj 
15013446Smrj /*******************************************************************************
15023446Smrj  *
15033446Smrj  * FUNCTION:    AcpiDmCompareAmlResources
15043446Smrj  *
15053446Smrj  * PARAMETERS:  Aml1Buffer          - Contains first resource list
15063446Smrj  *              Aml1BufferLength    - Length of first resource list
15073446Smrj  *              Aml2Buffer          - Contains second resource list
15083446Smrj  *              Aml2BufferLength    - Length of second resource list
15093446Smrj  *
15103446Smrj  * RETURN:      None
15113446Smrj  *
15123446Smrj  * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
15133446Smrj  *              order to isolate a miscompare to an individual resource)
15143446Smrj  *
15153446Smrj  ******************************************************************************/
15163446Smrj 
15173446Smrj static void
15183446Smrj AcpiDmCompareAmlResources (
15193446Smrj     UINT8                   *Aml1Buffer,
15203446Smrj     ACPI_RSDESC_SIZE        Aml1BufferLength,
15213446Smrj     UINT8                   *Aml2Buffer,
15223446Smrj     ACPI_RSDESC_SIZE        Aml2BufferLength)
15233446Smrj {
15243446Smrj     UINT8                   *Aml1;
15253446Smrj     UINT8                   *Aml2;
15263446Smrj     ACPI_RSDESC_SIZE        Aml1Length;
15273446Smrj     ACPI_RSDESC_SIZE        Aml2Length;
15283446Smrj     ACPI_RSDESC_SIZE        Offset = 0;
15293446Smrj     UINT8                   ResourceType;
15303446Smrj     UINT32                  Count = 0;
15313446Smrj 
15323446Smrj 
15333446Smrj     /* Compare overall buffer sizes (may be different due to size rounding) */
15343446Smrj 
15353446Smrj     if (Aml1BufferLength != Aml2BufferLength)
15363446Smrj     {
15373446Smrj         AcpiOsPrintf (
15383446Smrj             "**** Buffer length mismatch in converted AML: original %X new %X ****\n",
15393446Smrj             Aml1BufferLength, Aml2BufferLength);
15403446Smrj     }
15413446Smrj 
15423446Smrj     Aml1 = Aml1Buffer;
15433446Smrj     Aml2 = Aml2Buffer;
15443446Smrj 
15453446Smrj     /* Walk the descriptor lists, comparing each descriptor */
15463446Smrj 
15473446Smrj     while (Aml1 < (Aml1Buffer + Aml1BufferLength))
15483446Smrj     {
15493446Smrj         /* Get the lengths of each descriptor */
15503446Smrj 
15513446Smrj         Aml1Length = AcpiUtGetDescriptorLength (Aml1);
15523446Smrj         Aml2Length = AcpiUtGetDescriptorLength (Aml2);
15533446Smrj         ResourceType = AcpiUtGetResourceType (Aml1);
15543446Smrj 
15553446Smrj         /* Check for descriptor length match */
15563446Smrj 
15573446Smrj         if (Aml1Length != Aml2Length)
15583446Smrj         {
15593446Smrj             AcpiOsPrintf (
15603446Smrj                 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n",
15613446Smrj                 Count, ResourceType, Offset, Aml1Length, Aml2Length);
15623446Smrj         }
15633446Smrj 
15643446Smrj         /* Check for descriptor byte match */
15653446Smrj 
15663446Smrj         else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
15673446Smrj         {
15683446Smrj             AcpiOsPrintf (
15693446Smrj                 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
15703446Smrj                 Count, ResourceType, Offset);
15713446Smrj         }
15723446Smrj 
15733446Smrj         /* Exit on EndTag descriptor */
15743446Smrj 
15753446Smrj         if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
15763446Smrj         {
15773446Smrj             return;
15783446Smrj         }
15793446Smrj 
15803446Smrj         /* Point to next descriptor in each buffer */
15813446Smrj 
15823446Smrj         Count++;
15833446Smrj         Offset += Aml1Length;
15843446Smrj         Aml1 += Aml1Length;
15853446Smrj         Aml2 += Aml2Length;
15863446Smrj     }
15873446Smrj }
15883446Smrj 
15893446Smrj 
15903446Smrj /*******************************************************************************
15913446Smrj  *
15923446Smrj  * FUNCTION:    AcpiDmTestResourceConversion
15933446Smrj  *
15943446Smrj  * PARAMETERS:  Node            - Parent device node
15953446Smrj  *              Name            - resource method name (_CRS)
15963446Smrj  *
15973446Smrj  * RETURN:      Status
15983446Smrj  *
15993446Smrj  * DESCRIPTION: Compare the original AML with a conversion of the AML to
16003446Smrj  *              internal resource list, then back to AML.
16013446Smrj  *
16023446Smrj  ******************************************************************************/
16033446Smrj 
16043446Smrj static ACPI_STATUS
16053446Smrj AcpiDmTestResourceConversion (
16063446Smrj     ACPI_NAMESPACE_NODE     *Node,
16073446Smrj     char                    *Name)
16083446Smrj {
16093446Smrj     ACPI_STATUS             Status;
16103446Smrj     ACPI_BUFFER             ReturnObj;
16113446Smrj     ACPI_BUFFER             ResourceObj;
16123446Smrj     ACPI_BUFFER             NewAml;
16133446Smrj     ACPI_OBJECT             *OriginalAml;
16143446Smrj 
16153446Smrj 
16163446Smrj     AcpiOsPrintf ("Resource Conversion Comparison:\n");
16173446Smrj 
16183446Smrj     NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
16193446Smrj     ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
16203446Smrj     ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
16213446Smrj 
16223446Smrj     /* Get the original _CRS AML resource template */
16233446Smrj 
16243446Smrj     Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj);
16253446Smrj     if (ACPI_FAILURE (Status))
16263446Smrj     {
16273446Smrj         AcpiOsPrintf ("Could not obtain %s: %s\n",
16283446Smrj             Name, AcpiFormatException (Status));
16293446Smrj         return (Status);
16303446Smrj     }
16313446Smrj 
16323446Smrj     /* Get the AML resource template, converted to internal resource structs */
16333446Smrj 
16343446Smrj     Status = AcpiGetCurrentResources (Node, &ResourceObj);
16353446Smrj     if (ACPI_FAILURE (Status))
16363446Smrj     {
16373446Smrj         AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
16383446Smrj             AcpiFormatException (Status));
16393446Smrj         goto Exit1;
16403446Smrj     }
16413446Smrj 
16423446Smrj     /* Convert internal resource list to external AML resource template */
16433446Smrj 
16443446Smrj     Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml);
16453446Smrj     if (ACPI_FAILURE (Status))
16463446Smrj     {
16473446Smrj         AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
16483446Smrj             AcpiFormatException (Status));
16493446Smrj         goto Exit2;
16503446Smrj     }
16513446Smrj 
16523446Smrj     /* Compare original AML to the newly created AML resource list */
16533446Smrj 
16543446Smrj     OriginalAml = ReturnObj.Pointer;
16553446Smrj 
16563446Smrj     AcpiDmCompareAmlResources (
16577851SDana.Myers@Sun.COM         OriginalAml->Buffer.Pointer, (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
16587851SDana.Myers@Sun.COM         NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
16593446Smrj 
16603446Smrj     /* Cleanup and exit */
16613446Smrj 
16623446Smrj     ACPI_FREE (NewAml.Pointer);
16633446Smrj Exit2:
16643446Smrj     ACPI_FREE (ResourceObj.Pointer);
16653446Smrj Exit1:
16663446Smrj     ACPI_FREE (ReturnObj.Pointer);
16673446Smrj     return (Status);
16683446Smrj }
16693446Smrj 
16703446Smrj 
16713446Smrj /*******************************************************************************
16723446Smrj  *
16733446Smrj  * FUNCTION:    AcpiDbDisplayResources
16743446Smrj  *
16753446Smrj  * PARAMETERS:  ObjectArg       - String with hex value of the object
16763446Smrj  *
16773446Smrj  * RETURN:      None
16783446Smrj  *
16793446Smrj  * DESCRIPTION: Display the resource objects associated with a device.
16803446Smrj  *
16813446Smrj  ******************************************************************************/
16823446Smrj 
16833446Smrj void
16843446Smrj AcpiDbDisplayResources (
16853446Smrj     char                    *ObjectArg)
16863446Smrj {
16873446Smrj     ACPI_NAMESPACE_NODE     *Node;
16883446Smrj     ACPI_STATUS             Status;
16893446Smrj     ACPI_BUFFER             ReturnObj;
16903446Smrj 
16913446Smrj 
16923446Smrj     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
16933446Smrj     AcpiDbgLevel |= ACPI_LV_RESOURCES;
16943446Smrj 
16953446Smrj     /* Convert string to object pointer */
16963446Smrj 
16973446Smrj     Node = AcpiDbConvertToNode (ObjectArg);
16983446Smrj     if (!Node)
16993446Smrj     {
17003446Smrj         return;
17013446Smrj     }
17023446Smrj 
17033446Smrj     /* Prepare for a return object of arbitrary size */
17043446Smrj 
17053446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
17063446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
17073446Smrj 
17083446Smrj     /* _PRT */
17093446Smrj 
17103446Smrj     AcpiOsPrintf ("Evaluating _PRT\n");
17113446Smrj 
17123446Smrj     /* Check if _PRT exists */
17133446Smrj 
17143446Smrj     Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj);
17153446Smrj     if (ACPI_FAILURE (Status))
17163446Smrj     {
17173446Smrj         AcpiOsPrintf ("Could not obtain _PRT: %s\n",
17183446Smrj             AcpiFormatException (Status));
17193446Smrj         goto GetCrs;
17203446Smrj     }
17213446Smrj 
17223446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
17233446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
17243446Smrj 
17253446Smrj     Status = AcpiGetIrqRoutingTable (Node, &ReturnObj);
17263446Smrj     if (ACPI_FAILURE (Status))
17273446Smrj     {
17283446Smrj         AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
17293446Smrj             AcpiFormatException (Status));
17303446Smrj         goto GetCrs;
17313446Smrj     }
17323446Smrj 
17333446Smrj     AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
17343446Smrj 
17353446Smrj 
17363446Smrj     /* _CRS */
17373446Smrj 
17383446Smrj GetCrs:
17393446Smrj     AcpiOsPrintf ("Evaluating _CRS\n");
17403446Smrj 
17413446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
17423446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
17433446Smrj 
17443446Smrj     /* Check if _CRS exists */
17453446Smrj 
17463446Smrj     Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj);
17473446Smrj     if (ACPI_FAILURE (Status))
17483446Smrj     {
17493446Smrj         AcpiOsPrintf ("Could not obtain _CRS: %s\n",
17503446Smrj             AcpiFormatException (Status));
17513446Smrj         goto GetPrs;
17523446Smrj     }
17533446Smrj 
17543446Smrj     /* Get the _CRS resource list */
17553446Smrj 
17563446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
17573446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
17583446Smrj 
17593446Smrj     Status = AcpiGetCurrentResources (Node, &ReturnObj);
17603446Smrj     if (ACPI_FAILURE (Status))
17613446Smrj     {
17623446Smrj         AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
17633446Smrj             AcpiFormatException (Status));
17643446Smrj         goto GetPrs;
17653446Smrj     }
17663446Smrj 
17673446Smrj     /* Dump the _CRS resource list */
17683446Smrj 
17693446Smrj     AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
17703446Smrj         ReturnObj.Pointer));
17713446Smrj 
17723446Smrj     /*
17733446Smrj      * Perform comparison of original AML to newly created AML. This tests both
17743446Smrj      * the AML->Resource conversion and the Resource->Aml conversion.
17753446Smrj      */
17763446Smrj     Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
17773446Smrj 
17783446Smrj     /* Execute _SRS with the resource list */
17793446Smrj 
17803446Smrj     Status = AcpiSetCurrentResources (Node, &ReturnObj);
17813446Smrj     if (ACPI_FAILURE (Status))
17823446Smrj     {
17833446Smrj         AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
17843446Smrj             AcpiFormatException (Status));
17853446Smrj         goto GetPrs;
17863446Smrj     }
17873446Smrj 
17883446Smrj 
17893446Smrj     /* _PRS */
17903446Smrj 
17913446Smrj GetPrs:
17923446Smrj     AcpiOsPrintf ("Evaluating _PRS\n");
17933446Smrj 
17943446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
17953446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
17963446Smrj 
17973446Smrj     /* Check if _PRS exists */
17983446Smrj 
17993446Smrj     Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj);
18003446Smrj     if (ACPI_FAILURE (Status))
18013446Smrj     {
18023446Smrj         AcpiOsPrintf ("Could not obtain _PRS: %s\n",
18033446Smrj             AcpiFormatException (Status));
18043446Smrj         goto Cleanup;
18053446Smrj     }
18063446Smrj 
18073446Smrj     ReturnObj.Pointer = AcpiGbl_DbBuffer;
18083446Smrj     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
18093446Smrj 
18103446Smrj     Status = AcpiGetPossibleResources (Node, &ReturnObj);
18113446Smrj     if (ACPI_FAILURE (Status))
18123446Smrj     {
18133446Smrj         AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
18143446Smrj             AcpiFormatException (Status));
18153446Smrj         goto Cleanup;
18163446Smrj     }
18173446Smrj 
18183446Smrj     AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
18193446Smrj 
18203446Smrj Cleanup:
18213446Smrj 
18223446Smrj     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
18233446Smrj     return;
18243446Smrj }
18253446Smrj 
18263446Smrj 
18273446Smrj /*******************************************************************************
18283446Smrj  *
18293446Smrj  * FUNCTION:    AcpiDbIntegrityWalk
18303446Smrj  *
18313446Smrj  * PARAMETERS:  Callback from WalkNamespace
18323446Smrj  *
18333446Smrj  * RETURN:      Status
18343446Smrj  *
18353446Smrj  * DESCRIPTION: Examine one NS node for valid values.
18363446Smrj  *
18373446Smrj  ******************************************************************************/
18383446Smrj 
18393446Smrj static ACPI_STATUS
18403446Smrj AcpiDbIntegrityWalk (
18413446Smrj     ACPI_HANDLE             ObjHandle,
18423446Smrj     UINT32                  NestingLevel,
18433446Smrj     void                    *Context,
18443446Smrj     void                    **ReturnValue)
18453446Smrj {
18463446Smrj     ACPI_INTEGRITY_INFO     *Info = (ACPI_INTEGRITY_INFO *) Context;
18473446Smrj     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
18483446Smrj     ACPI_OPERAND_OBJECT     *Object;
18497851SDana.Myers@Sun.COM     BOOLEAN                 Alias = TRUE;
18503446Smrj 
18513446Smrj 
18523446Smrj     Info->Nodes++;
18537851SDana.Myers@Sun.COM 
18547851SDana.Myers@Sun.COM     /* Verify the NS node, and dereference aliases */
18557851SDana.Myers@Sun.COM 
18567851SDana.Myers@Sun.COM     while (Alias)
18573446Smrj     {
18587851SDana.Myers@Sun.COM         if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
18597851SDana.Myers@Sun.COM         {
18607851SDana.Myers@Sun.COM             AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n",
18617851SDana.Myers@Sun.COM                 Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node),
18627851SDana.Myers@Sun.COM                 ACPI_DESC_TYPE_NAMED);
18637851SDana.Myers@Sun.COM             return (AE_OK);
18647851SDana.Myers@Sun.COM         }
18657851SDana.Myers@Sun.COM 
18667851SDana.Myers@Sun.COM         if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
18677851SDana.Myers@Sun.COM             (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
18687851SDana.Myers@Sun.COM         {
18697851SDana.Myers@Sun.COM             Node = (ACPI_NAMESPACE_NODE *) Node->Object;
18707851SDana.Myers@Sun.COM         }
18717851SDana.Myers@Sun.COM         else
18727851SDana.Myers@Sun.COM         {
18737851SDana.Myers@Sun.COM             Alias = FALSE;
18747851SDana.Myers@Sun.COM         }
18753446Smrj     }
18763446Smrj 
18773446Smrj     if (Node->Type > ACPI_TYPE_LOCAL_MAX)
18783446Smrj     {
18793446Smrj         AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
18803446Smrj             Node, Node->Type);
18817851SDana.Myers@Sun.COM         return (AE_OK);
18823446Smrj     }
18833446Smrj 
18843446Smrj     if (!AcpiUtValidAcpiName (Node->Name.Integer))
18853446Smrj     {
18863446Smrj         AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
18877851SDana.Myers@Sun.COM         return (AE_OK);
18883446Smrj     }
18893446Smrj 
18903446Smrj     Object = AcpiNsGetAttachedObject (Node);
18913446Smrj     if (Object)
18923446Smrj     {
18933446Smrj         Info->Objects++;
18943446Smrj         if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
18953446Smrj         {
18963446Smrj             AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
18973446Smrj                 Object, AcpiUtGetDescriptorName (Object));
18983446Smrj         }
18993446Smrj     }
19003446Smrj 
19013446Smrj     return (AE_OK);
19023446Smrj }
19033446Smrj 
19043446Smrj 
19053446Smrj /*******************************************************************************
19063446Smrj  *
19073446Smrj  * FUNCTION:    AcpiDbCheckIntegrity
19083446Smrj  *
19093446Smrj  * PARAMETERS:  None
19103446Smrj  *
19113446Smrj  * RETURN:      None
19123446Smrj  *
19133446Smrj  * DESCRIPTION: Check entire namespace for data structure integrity
19143446Smrj  *
19153446Smrj  ******************************************************************************/
19163446Smrj 
19173446Smrj void
19183446Smrj AcpiDbCheckIntegrity (
19193446Smrj     void)
19203446Smrj {
19213446Smrj     ACPI_INTEGRITY_INFO     Info = {0,0};
19223446Smrj 
19233446Smrj     /* Search all nodes in namespace */
19243446Smrj 
19253446Smrj     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
19263446Smrj                     AcpiDbIntegrityWalk, (void *) &Info, NULL);
19273446Smrj 
19283446Smrj     AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n",
19293446Smrj         Info.Nodes, Info.Objects);
19303446Smrj }
19313446Smrj 
19323446Smrj 
19333446Smrj /*******************************************************************************
19343446Smrj  *
19353446Smrj  * FUNCTION:    AcpiDbGenerateGpe
19363446Smrj  *
19373446Smrj  * PARAMETERS:  GpeArg          - Raw GPE number, ascii string
19383446Smrj  *              BlockArg        - GPE block number, ascii string
19393446Smrj  *                                0 or 1 for FADT GPE blocks
19403446Smrj  *
19413446Smrj  * RETURN:      None
19423446Smrj  *
19433446Smrj  * DESCRIPTION: Generate a GPE
19443446Smrj  *
19453446Smrj  ******************************************************************************/
19463446Smrj 
19473446Smrj void
19483446Smrj AcpiDbGenerateGpe (
19493446Smrj     char                    *GpeArg,
19503446Smrj     char                    *BlockArg)
19513446Smrj {
19523446Smrj     UINT32                  BlockNumber;
19533446Smrj     UINT32                  GpeNumber;
19543446Smrj     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
19553446Smrj 
19563446Smrj 
19573446Smrj     GpeNumber   = ACPI_STRTOUL (GpeArg, NULL, 0);
19583446Smrj     BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
19593446Smrj 
19603446Smrj 
19613446Smrj     GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
19623446Smrj         GpeNumber);
19633446Smrj     if (!GpeEventInfo)
19643446Smrj     {
19653446Smrj         AcpiOsPrintf ("Invalid GPE\n");
19663446Smrj         return;
19673446Smrj     }
19683446Smrj 
19693446Smrj     (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber);
19703446Smrj }
19713446Smrj 
19723446Smrj 
19733446Smrj /*******************************************************************************
19743446Smrj  *
19753446Smrj  * FUNCTION:    AcpiDbBusWalk
19763446Smrj  *
19773446Smrj  * PARAMETERS:  Callback from WalkNamespace
19783446Smrj  *
19793446Smrj  * RETURN:      Status
19803446Smrj  *
19813446Smrj  * DESCRIPTION: Display info about device objects that have a corresponding
19823446Smrj  *              _PRT method.
19833446Smrj  *
19843446Smrj  ******************************************************************************/
19853446Smrj 
19863446Smrj static ACPI_STATUS
19873446Smrj AcpiDbBusWalk (
19883446Smrj     ACPI_HANDLE             ObjHandle,
19893446Smrj     UINT32                  NestingLevel,
19903446Smrj     void                    *Context,
19913446Smrj     void                    **ReturnValue)
19923446Smrj {
19933446Smrj     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
19943446Smrj     ACPI_STATUS             Status;
19953446Smrj     ACPI_BUFFER             Buffer;
19963446Smrj     ACPI_INTEGER            ADR;
19973446Smrj     ACPI_DEVICE_ID          Id;
19983446Smrj     ACPI_COMPATIBLE_ID_LIST *Cid;
19993446Smrj     ACPI_NAMESPACE_NODE     *TempNode;
20003446Smrj 
20013446Smrj 
20023446Smrj     /* Exit if there is no _PRT under this device */
20033446Smrj 
20043446Smrj     Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
20053446Smrj                 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
20063446Smrj     if (ACPI_FAILURE (Status))
20073446Smrj     {
20083446Smrj         return (AE_OK);
20093446Smrj     }
20103446Smrj 
20113446Smrj     /* Get the full path to this device object */
20123446Smrj 
20133446Smrj     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
20143446Smrj     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
20153446Smrj     if (ACPI_FAILURE (Status))
20163446Smrj     {
20173446Smrj         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
20183446Smrj         return (AE_OK);
20193446Smrj     }
20203446Smrj 
20213446Smrj     /* Display the full path */
20223446Smrj 
20233446Smrj     AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer);
20243446Smrj     ACPI_FREE (Buffer.Pointer);
20253446Smrj 
20263446Smrj     /* _PRT info */
20273446Smrj 
20283446Smrj     AcpiOsPrintf ("_PRT=%p", TempNode);
20293446Smrj 
20303446Smrj     /* Get the _ADR value */
20313446Smrj 
20323446Smrj     Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &ADR);
20333446Smrj     if (ACPI_FAILURE (Status))
20343446Smrj     {
20353446Smrj         AcpiOsPrintf (" No _ADR      ");
20363446Smrj     }
20373446Smrj     else
20383446Smrj     {
20393446Smrj         AcpiOsPrintf (" _ADR=%8.8X", (UINT32) ADR);
20403446Smrj     }
20413446Smrj 
20423446Smrj     /* Get the _HID if present */
20433446Smrj 
20443446Smrj     Status = AcpiUtExecute_HID (Node, &Id);
20453446Smrj     if (ACPI_SUCCESS (Status))
20463446Smrj     {
20473446Smrj         AcpiOsPrintf (" _HID=%s", Id.Value);
20483446Smrj     }
20493446Smrj     else
20503446Smrj     {
20513446Smrj         AcpiOsPrintf ("             ");
20523446Smrj     }
20533446Smrj 
20543446Smrj     /* Get the _UID if present */
20553446Smrj 
20563446Smrj     Status = AcpiUtExecute_UID (Node, &Id);
20573446Smrj     if (ACPI_SUCCESS (Status))
20583446Smrj     {
20593446Smrj         AcpiOsPrintf (" _UID=%s", Id.Value);
20603446Smrj     }
20613446Smrj 
20623446Smrj     /* Get the _CID if present */
20633446Smrj 
20643446Smrj     Status = AcpiUtExecute_CID (Node, &Cid);
20653446Smrj     if (ACPI_SUCCESS (Status))
20663446Smrj     {
20673446Smrj         AcpiOsPrintf (" _CID=%s", Cid->Id[0].Value);
20683446Smrj         ACPI_FREE (Cid);
20693446Smrj     }
20703446Smrj 
20713446Smrj     AcpiOsPrintf ("\n");
20723446Smrj     return (AE_OK);
20733446Smrj }
20743446Smrj 
20753446Smrj 
20763446Smrj /*******************************************************************************
20773446Smrj  *
20783446Smrj  * FUNCTION:    AcpiDbGetBusInfo
20793446Smrj  *
20803446Smrj  * PARAMETERS:  None
20813446Smrj  *
20823446Smrj  * RETURN:      None
20833446Smrj  *
20843446Smrj  * DESCRIPTION: Display info about system busses.
20853446Smrj  *
20863446Smrj  ******************************************************************************/
20873446Smrj 
20883446Smrj void
20893446Smrj AcpiDbGetBusInfo (
20903446Smrj     void)
20913446Smrj {
20923446Smrj     /* Search all nodes in namespace */
20933446Smrj 
20943446Smrj     (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
20953446Smrj                     AcpiDbBusWalk, NULL, NULL);
20963446Smrj }
20973446Smrj 
20983446Smrj #endif /* ACPI_DEBUGGER */
2099