Home | History | Annotate | Line # | Download | only in debugger
dbcmds.c revision 1.18.6.1
      1       1.1    jruoho /*******************************************************************************
      2       1.1    jruoho  *
      3       1.3    jruoho  * Module Name: dbcmds - Miscellaneous debug commands and output routines
      4       1.1    jruoho  *
      5       1.1    jruoho  ******************************************************************************/
      6       1.1    jruoho 
      7  1.18.6.1  perseant /******************************************************************************
      8  1.18.6.1  perseant  *
      9  1.18.6.1  perseant  * 1. Copyright Notice
     10  1.18.6.1  perseant  *
     11  1.18.6.1  perseant  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
     12       1.1    jruoho  * All rights reserved.
     13       1.1    jruoho  *
     14  1.18.6.1  perseant  * 2. License
     15  1.18.6.1  perseant  *
     16  1.18.6.1  perseant  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.18.6.1  perseant  * rights. You may have additional license terms from the party that provided
     18  1.18.6.1  perseant  * you this software, covering your right to use that party's intellectual
     19  1.18.6.1  perseant  * property rights.
     20  1.18.6.1  perseant  *
     21  1.18.6.1  perseant  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.18.6.1  perseant  * copy of the source code appearing in this file ("Covered Code") an
     23  1.18.6.1  perseant  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.18.6.1  perseant  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.18.6.1  perseant  * make derivatives, distribute, use and display any portion of the Covered
     26  1.18.6.1  perseant  * Code in any form, with the right to sublicense such rights; and
     27  1.18.6.1  perseant  *
     28  1.18.6.1  perseant  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.18.6.1  perseant  * license (with the right to sublicense), under only those claims of Intel
     30  1.18.6.1  perseant  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.18.6.1  perseant  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.18.6.1  perseant  * solely to the minimum extent necessary to exercise the above copyright
     33  1.18.6.1  perseant  * license, and in no event shall the patent license extend to any additions
     34  1.18.6.1  perseant  * to or modifications of the Original Intel Code. No other license or right
     35  1.18.6.1  perseant  * is granted directly or by implication, estoppel or otherwise;
     36  1.18.6.1  perseant  *
     37  1.18.6.1  perseant  * The above copyright and patent license is granted only if the following
     38  1.18.6.1  perseant  * conditions are met:
     39  1.18.6.1  perseant  *
     40  1.18.6.1  perseant  * 3. Conditions
     41  1.18.6.1  perseant  *
     42  1.18.6.1  perseant  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.18.6.1  perseant  * Redistribution of source code of any substantial portion of the Covered
     44  1.18.6.1  perseant  * Code or modification with rights to further distribute source must include
     45  1.18.6.1  perseant  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.18.6.1  perseant  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.18.6.1  perseant  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.18.6.1  perseant  * contain a file documenting the changes Licensee made to create that Covered
     49  1.18.6.1  perseant  * Code and the date of any change. Licensee must include in that file the
     50  1.18.6.1  perseant  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.18.6.1  perseant  * must include a prominent statement that the modification is derived,
     52  1.18.6.1  perseant  * directly or indirectly, from Original Intel Code.
     53  1.18.6.1  perseant  *
     54  1.18.6.1  perseant  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.18.6.1  perseant  * Redistribution of source code of any substantial portion of the Covered
     56  1.18.6.1  perseant  * Code or modification without rights to further distribute source must
     57  1.18.6.1  perseant  * include the following Disclaimer and Export Compliance provision in the
     58  1.18.6.1  perseant  * documentation and/or other materials provided with distribution. In
     59  1.18.6.1  perseant  * addition, Licensee may not authorize further sublicense of source of any
     60  1.18.6.1  perseant  * portion of the Covered Code, and must include terms to the effect that the
     61  1.18.6.1  perseant  * license from Licensee to its licensee is limited to the intellectual
     62  1.18.6.1  perseant  * property embodied in the software Licensee provides to its licensee, and
     63  1.18.6.1  perseant  * not to intellectual property embodied in modifications its licensee may
     64  1.18.6.1  perseant  * make.
     65  1.18.6.1  perseant  *
     66  1.18.6.1  perseant  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.18.6.1  perseant  * substantial portion of the Covered Code or modification must reproduce the
     68  1.18.6.1  perseant  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.18.6.1  perseant  * provision in the documentation and/or other materials provided with the
     70  1.18.6.1  perseant  * distribution.
     71  1.18.6.1  perseant  *
     72  1.18.6.1  perseant  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.18.6.1  perseant  * Intel Code.
     74  1.18.6.1  perseant  *
     75  1.18.6.1  perseant  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.18.6.1  perseant  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.18.6.1  perseant  * other dealings in products derived from or relating to the Covered Code
     78  1.18.6.1  perseant  * without prior written authorization from Intel.
     79  1.18.6.1  perseant  *
     80  1.18.6.1  perseant  * 4. Disclaimer and Export Compliance
     81  1.18.6.1  perseant  *
     82  1.18.6.1  perseant  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.18.6.1  perseant  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.18.6.1  perseant  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.18.6.1  perseant  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.18.6.1  perseant  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.18.6.1  perseant  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.18.6.1  perseant  * PARTICULAR PURPOSE.
     89  1.18.6.1  perseant  *
     90  1.18.6.1  perseant  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.18.6.1  perseant  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.18.6.1  perseant  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.18.6.1  perseant  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.18.6.1  perseant  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.18.6.1  perseant  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.18.6.1  perseant  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.18.6.1  perseant  * LIMITED REMEDY.
     98  1.18.6.1  perseant  *
     99  1.18.6.1  perseant  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.18.6.1  perseant  * software or system incorporating such software without first obtaining any
    101  1.18.6.1  perseant  * required license or other approval from the U. S. Department of Commerce or
    102  1.18.6.1  perseant  * any other agency or department of the United States Government. In the
    103  1.18.6.1  perseant  * event Licensee exports any such software from the United States or
    104  1.18.6.1  perseant  * re-exports any such software from a foreign destination, Licensee shall
    105  1.18.6.1  perseant  * ensure that the distribution and export/re-export of the software is in
    106  1.18.6.1  perseant  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.18.6.1  perseant  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.18.6.1  perseant  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.18.6.1  perseant  * software, or service, directly or indirectly, to any country for which the
    110  1.18.6.1  perseant  * United States government or any agency thereof requires an export license,
    111  1.18.6.1  perseant  * other governmental approval, or letter of assurance, without first obtaining
    112  1.18.6.1  perseant  * such license, approval or letter.
    113  1.18.6.1  perseant  *
    114  1.18.6.1  perseant  *****************************************************************************
    115  1.18.6.1  perseant  *
    116  1.18.6.1  perseant  * Alternatively, you may choose to be licensed under the terms of the
    117  1.18.6.1  perseant  * following license:
    118  1.18.6.1  perseant  *
    119       1.3    jruoho  * Redistribution and use in source and binary forms, with or without
    120       1.3    jruoho  * modification, are permitted provided that the following conditions
    121       1.3    jruoho  * are met:
    122       1.3    jruoho  * 1. Redistributions of source code must retain the above copyright
    123       1.3    jruoho  *    notice, this list of conditions, and the following disclaimer,
    124       1.3    jruoho  *    without modification.
    125       1.3    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126       1.3    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
    127       1.3    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
    128       1.3    jruoho  *    including a substantially similar Disclaimer requirement for further
    129       1.3    jruoho  *    binary redistribution.
    130       1.3    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
    131       1.3    jruoho  *    of any contributors may be used to endorse or promote products derived
    132       1.3    jruoho  *    from this software without specific prior written permission.
    133       1.3    jruoho  *
    134       1.3    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135       1.3    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136      1.15  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137       1.3    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  1.18.6.1  perseant  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.18.6.1  perseant  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.18.6.1  perseant  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.18.6.1  perseant  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.18.6.1  perseant  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.18.6.1  perseant  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.18.6.1  perseant  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.18.6.1  perseant  *
    146  1.18.6.1  perseant  * Alternatively, you may choose to be licensed under the terms of the
    147  1.18.6.1  perseant  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.18.6.1  perseant  * Software Foundation.
    149  1.18.6.1  perseant  *
    150  1.18.6.1  perseant  *****************************************************************************/
    151       1.1    jruoho 
    152       1.1    jruoho #include "acpi.h"
    153       1.1    jruoho #include "accommon.h"
    154       1.1    jruoho #include "acevents.h"
    155       1.1    jruoho #include "acdebug.h"
    156       1.4  christos #include "acnamesp.h"
    157       1.1    jruoho #include "acresrc.h"
    158       1.1    jruoho #include "actables.h"
    159      1.18  christos #ifndef _KERNEL
    160      1.17  christos #include "limits.h"
    161      1.18  christos #endif
    162       1.1    jruoho 
    163       1.1    jruoho #define _COMPONENT          ACPI_CA_DEBUGGER
    164       1.1    jruoho         ACPI_MODULE_NAME    ("dbcmds")
    165       1.1    jruoho 
    166       1.1    jruoho 
    167       1.1    jruoho /* Local prototypes */
    168       1.1    jruoho 
    169       1.1    jruoho static void
    170       1.1    jruoho AcpiDmCompareAmlResources (
    171       1.1    jruoho     UINT8                   *Aml1Buffer,
    172       1.1    jruoho     ACPI_RSDESC_SIZE        Aml1BufferLength,
    173       1.1    jruoho     UINT8                   *Aml2Buffer,
    174       1.1    jruoho     ACPI_RSDESC_SIZE        Aml2BufferLength);
    175       1.1    jruoho 
    176       1.1    jruoho static ACPI_STATUS
    177       1.1    jruoho AcpiDmTestResourceConversion (
    178       1.1    jruoho     ACPI_NAMESPACE_NODE     *Node,
    179       1.1    jruoho     char                    *Name);
    180       1.1    jruoho 
    181       1.4  christos static ACPI_STATUS
    182       1.4  christos AcpiDbResourceCallback (
    183       1.4  christos     ACPI_RESOURCE           *Resource,
    184       1.4  christos     void                    *Context);
    185       1.4  christos 
    186       1.4  christos static ACPI_STATUS
    187       1.4  christos AcpiDbDeviceResources (
    188       1.4  christos     ACPI_HANDLE             ObjHandle,
    189       1.4  christos     UINT32                  NestingLevel,
    190       1.4  christos     void                    *Context,
    191       1.4  christos     void                    **ReturnValue);
    192       1.4  christos 
    193       1.4  christos static void
    194       1.4  christos AcpiDbDoOneSleepState (
    195       1.4  christos     UINT8                   SleepState);
    196       1.4  christos 
    197       1.1    jruoho 
    198       1.8  christos static char                 *AcpiDbTraceMethodName = NULL;
    199       1.8  christos 
    200       1.9  christos 
    201       1.1    jruoho /*******************************************************************************
    202       1.1    jruoho  *
    203       1.1    jruoho  * FUNCTION:    AcpiDbConvertToNode
    204       1.1    jruoho  *
    205       1.4  christos  * PARAMETERS:  InString            - String to convert
    206       1.1    jruoho  *
    207       1.1    jruoho  * RETURN:      Pointer to a NS node
    208       1.1    jruoho  *
    209       1.4  christos  * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
    210       1.4  christos  *              alphanumeric strings.
    211       1.1    jruoho  *
    212       1.1    jruoho  ******************************************************************************/
    213       1.1    jruoho 
    214       1.3    jruoho ACPI_NAMESPACE_NODE *
    215       1.1    jruoho AcpiDbConvertToNode (
    216       1.1    jruoho     char                    *InString)
    217       1.1    jruoho {
    218       1.1    jruoho     ACPI_NAMESPACE_NODE     *Node;
    219       1.4  christos     ACPI_SIZE               Address;
    220       1.1    jruoho 
    221       1.1    jruoho 
    222       1.1    jruoho     if ((*InString >= 0x30) && (*InString <= 0x39))
    223       1.1    jruoho     {
    224       1.1    jruoho         /* Numeric argument, convert */
    225       1.1    jruoho 
    226       1.8  christos         Address = strtoul (InString, NULL, 16);
    227       1.4  christos         Node = ACPI_TO_POINTER (Address);
    228       1.1    jruoho         if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
    229       1.1    jruoho         {
    230       1.9  christos             AcpiOsPrintf ("Address %p is invalid", Node);
    231       1.1    jruoho             return (NULL);
    232       1.1    jruoho         }
    233       1.1    jruoho 
    234       1.1    jruoho         /* Make sure pointer is valid NS node */
    235       1.1    jruoho 
    236       1.1    jruoho         if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
    237       1.1    jruoho         {
    238       1.6  christos             AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n",
    239       1.9  christos                 Node, AcpiUtGetDescriptorName (Node));
    240       1.1    jruoho             return (NULL);
    241       1.1    jruoho         }
    242       1.1    jruoho     }
    243       1.1    jruoho     else
    244       1.1    jruoho     {
    245       1.4  christos         /*
    246       1.4  christos          * Alpha argument: The parameter is a name string that must be
    247       1.4  christos          * resolved to a Namespace object.
    248       1.1    jruoho          */
    249       1.1    jruoho         Node = AcpiDbLocalNsLookup (InString);
    250       1.1    jruoho         if (!Node)
    251       1.1    jruoho         {
    252       1.9  christos             AcpiOsPrintf (
    253       1.9  christos                 "Could not find [%s] in namespace, defaulting to root node\n",
    254       1.6  christos                 InString);
    255       1.1    jruoho             Node = AcpiGbl_RootNode;
    256       1.1    jruoho         }
    257       1.1    jruoho     }
    258       1.1    jruoho 
    259       1.1    jruoho     return (Node);
    260       1.1    jruoho }
    261       1.1    jruoho 
    262       1.1    jruoho 
    263       1.1    jruoho /*******************************************************************************
    264       1.1    jruoho  *
    265       1.1    jruoho  * FUNCTION:    AcpiDbSleep
    266       1.1    jruoho  *
    267       1.4  christos  * PARAMETERS:  ObjectArg           - Desired sleep state (0-5). NULL means
    268       1.4  christos  *                                    invoke all possible sleep states.
    269       1.1    jruoho  *
    270       1.1    jruoho  * RETURN:      Status
    271       1.1    jruoho  *
    272       1.4  christos  * DESCRIPTION: Simulate sleep/wake sequences
    273       1.1    jruoho  *
    274       1.1    jruoho  ******************************************************************************/
    275       1.1    jruoho 
    276       1.1    jruoho ACPI_STATUS
    277       1.1    jruoho AcpiDbSleep (
    278       1.1    jruoho     char                    *ObjectArg)
    279       1.1    jruoho {
    280       1.1    jruoho     UINT8                   SleepState;
    281       1.4  christos     UINT32                  i;
    282       1.4  christos 
    283       1.4  christos 
    284       1.4  christos     ACPI_FUNCTION_TRACE (AcpiDbSleep);
    285       1.4  christos 
    286       1.4  christos 
    287       1.4  christos     /* Null input (no arguments) means to invoke all sleep states */
    288       1.4  christos 
    289       1.4  christos     if (!ObjectArg)
    290       1.4  christos     {
    291       1.4  christos         AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n",
    292       1.4  christos             ACPI_S_STATES_MAX);
    293       1.4  christos 
    294       1.4  christos         for (i = 0; i <= ACPI_S_STATES_MAX; i++)
    295       1.4  christos         {
    296       1.4  christos             AcpiDbDoOneSleepState ((UINT8) i);
    297       1.4  christos         }
    298       1.4  christos 
    299       1.4  christos         return_ACPI_STATUS (AE_OK);
    300       1.4  christos     }
    301       1.1    jruoho 
    302       1.4  christos     /* Convert argument to binary and invoke the sleep state */
    303       1.1    jruoho 
    304       1.8  christos     SleepState = (UINT8) strtoul (ObjectArg, NULL, 0);
    305       1.4  christos     AcpiDbDoOneSleepState (SleepState);
    306       1.4  christos     return_ACPI_STATUS (AE_OK);
    307       1.4  christos }
    308       1.4  christos 
    309       1.4  christos 
    310       1.4  christos /*******************************************************************************
    311       1.4  christos  *
    312       1.4  christos  * FUNCTION:    AcpiDbDoOneSleepState
    313       1.4  christos  *
    314       1.4  christos  * PARAMETERS:  SleepState          - Desired sleep state (0-5)
    315       1.4  christos  *
    316       1.9  christos  * RETURN:      None
    317       1.4  christos  *
    318       1.4  christos  * DESCRIPTION: Simulate a sleep/wake sequence
    319       1.4  christos  *
    320       1.4  christos  ******************************************************************************/
    321       1.4  christos 
    322       1.4  christos static void
    323       1.4  christos AcpiDbDoOneSleepState (
    324       1.4  christos     UINT8                   SleepState)
    325       1.4  christos {
    326       1.4  christos     ACPI_STATUS             Status;
    327       1.4  christos     UINT8                   SleepTypeA;
    328       1.4  christos     UINT8                   SleepTypeB;
    329       1.4  christos 
    330       1.4  christos 
    331       1.4  christos     /* Validate parameter */
    332       1.4  christos 
    333       1.4  christos     if (SleepState > ACPI_S_STATES_MAX)
    334       1.4  christos     {
    335       1.4  christos         AcpiOsPrintf ("Sleep state %d out of range (%d max)\n",
    336       1.4  christos             SleepState, ACPI_S_STATES_MAX);
    337       1.4  christos         return;
    338       1.4  christos     }
    339       1.4  christos 
    340       1.4  christos     AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n",
    341       1.4  christos         SleepState, AcpiGbl_SleepStateNames[SleepState]);
    342       1.4  christos 
    343       1.4  christos     /* Get the values for the sleep type registers (for display only) */
    344       1.4  christos 
    345       1.4  christos     Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB);
    346       1.4  christos     if (ACPI_FAILURE (Status))
    347       1.4  christos     {
    348       1.4  christos         AcpiOsPrintf ("Could not evaluate [%s] method, %s\n",
    349       1.4  christos             AcpiGbl_SleepStateNames[SleepState],
    350       1.4  christos             AcpiFormatException (Status));
    351       1.4  christos         return;
    352       1.4  christos     }
    353       1.1    jruoho 
    354       1.4  christos     AcpiOsPrintf (
    355       1.4  christos         "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
    356       1.4  christos         SleepState, SleepTypeA, SleepTypeB);
    357       1.4  christos 
    358       1.4  christos     /* Invoke the various sleep/wake interfaces */
    359       1.4  christos 
    360       1.4  christos     AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n",
    361       1.4  christos         SleepState);
    362       1.1    jruoho     Status = AcpiEnterSleepStatePrep (SleepState);
    363       1.1    jruoho     if (ACPI_FAILURE (Status))
    364       1.1    jruoho     {
    365       1.4  christos         goto ErrorExit;
    366       1.1    jruoho     }
    367       1.1    jruoho 
    368       1.4  christos     AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n",
    369       1.4  christos         SleepState);
    370       1.1    jruoho     Status = AcpiEnterSleepState (SleepState);
    371       1.1    jruoho     if (ACPI_FAILURE (Status))
    372       1.1    jruoho     {
    373       1.4  christos         goto ErrorExit;
    374       1.4  christos     }
    375       1.4  christos 
    376       1.4  christos     AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n",
    377       1.4  christos         SleepState);
    378       1.4  christos     Status = AcpiLeaveSleepStatePrep (SleepState);
    379       1.4  christos     if (ACPI_FAILURE (Status))
    380       1.4  christos     {
    381       1.4  christos         goto ErrorExit;
    382       1.1    jruoho     }
    383       1.1    jruoho 
    384       1.4  christos     AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n",
    385       1.4  christos         SleepState);
    386       1.1    jruoho     Status = AcpiLeaveSleepState (SleepState);
    387       1.4  christos     if (ACPI_FAILURE (Status))
    388       1.4  christos     {
    389       1.4  christos         goto ErrorExit;
    390       1.4  christos     }
    391       1.4  christos 
    392       1.4  christos     return;
    393       1.1    jruoho 
    394       1.4  christos 
    395       1.4  christos ErrorExit:
    396       1.4  christos     ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d",
    397       1.4  christos         SleepState));
    398       1.1    jruoho }
    399       1.1    jruoho 
    400       1.4  christos 
    401       1.1    jruoho /*******************************************************************************
    402       1.1    jruoho  *
    403       1.1    jruoho  * FUNCTION:    AcpiDbDisplayLocks
    404       1.1    jruoho  *
    405       1.1    jruoho  * PARAMETERS:  None
    406       1.1    jruoho  *
    407       1.1    jruoho  * RETURN:      None
    408       1.1    jruoho  *
    409       1.1    jruoho  * DESCRIPTION: Display information about internal mutexes.
    410       1.1    jruoho  *
    411       1.1    jruoho  ******************************************************************************/
    412       1.1    jruoho 
    413       1.1    jruoho void
    414       1.1    jruoho AcpiDbDisplayLocks (
    415       1.1    jruoho     void)
    416       1.1    jruoho {
    417       1.1    jruoho     UINT32                  i;
    418       1.1    jruoho 
    419       1.1    jruoho 
    420       1.1    jruoho     for (i = 0; i < ACPI_MAX_MUTEX; i++)
    421       1.1    jruoho     {
    422       1.1    jruoho         AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
    423       1.1    jruoho             AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
    424       1.1    jruoho                 ? "Locked" : "Unlocked");
    425       1.1    jruoho     }
    426       1.1    jruoho }
    427       1.1    jruoho 
    428       1.1    jruoho 
    429       1.1    jruoho /*******************************************************************************
    430       1.1    jruoho  *
    431       1.1    jruoho  * FUNCTION:    AcpiDbDisplayTableInfo
    432       1.1    jruoho  *
    433       1.4  christos  * PARAMETERS:  TableArg            - Name of table to be displayed
    434       1.1    jruoho  *
    435       1.1    jruoho  * RETURN:      None
    436       1.1    jruoho  *
    437       1.4  christos  * DESCRIPTION: Display information about loaded tables. Current
    438       1.1    jruoho  *              implementation displays all loaded tables.
    439       1.1    jruoho  *
    440       1.1    jruoho  ******************************************************************************/
    441       1.1    jruoho 
    442       1.1    jruoho void
    443       1.1    jruoho AcpiDbDisplayTableInfo (
    444       1.1    jruoho     char                    *TableArg)
    445       1.1    jruoho {
    446       1.1    jruoho     UINT32                  i;
    447       1.1    jruoho     ACPI_TABLE_DESC         *TableDesc;
    448       1.1    jruoho     ACPI_STATUS             Status;
    449       1.1    jruoho 
    450       1.1    jruoho 
    451       1.4  christos     /* Header */
    452       1.4  christos 
    453       1.9  christos     AcpiOsPrintf ("Idx ID    Status Type                    "
    454       1.9  christos         "TableHeader (Sig, Address, Length, Misc)\n");
    455       1.4  christos 
    456       1.1    jruoho     /* Walk the entire root table list */
    457       1.1    jruoho 
    458       1.1    jruoho     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
    459       1.1    jruoho     {
    460       1.1    jruoho         TableDesc = &AcpiGbl_RootTableList.Tables[i];
    461       1.4  christos 
    462       1.4  christos         /* Index and Table ID */
    463       1.4  christos 
    464       1.4  christos         AcpiOsPrintf ("%3u %.2u ", i, TableDesc->OwnerId);
    465       1.4  christos 
    466       1.4  christos         /* Decode the table flags */
    467       1.4  christos 
    468       1.4  christos         if (!(TableDesc->Flags & ACPI_TABLE_IS_LOADED))
    469       1.4  christos         {
    470       1.4  christos             AcpiOsPrintf ("NotLoaded ");
    471       1.4  christos         }
    472       1.4  christos         else
    473       1.4  christos         {
    474       1.4  christos             AcpiOsPrintf ("   Loaded ");
    475       1.4  christos         }
    476       1.4  christos 
    477       1.4  christos         switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
    478       1.4  christos         {
    479       1.6  christos         case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
    480       1.4  christos 
    481       1.6  christos             AcpiOsPrintf ("External/virtual  ");
    482       1.4  christos             break;
    483       1.4  christos 
    484       1.6  christos         case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
    485       1.4  christos 
    486       1.6  christos             AcpiOsPrintf ("Internal/physical ");
    487       1.4  christos             break;
    488       1.4  christos 
    489       1.6  christos         case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
    490       1.4  christos 
    491       1.6  christos             AcpiOsPrintf ("Internal/virtual  ");
    492       1.4  christos             break;
    493       1.4  christos 
    494       1.4  christos         default:
    495       1.4  christos 
    496       1.6  christos             AcpiOsPrintf ("INVALID TYPE      ");
    497       1.4  christos             break;
    498       1.4  christos         }
    499       1.1    jruoho 
    500       1.1    jruoho         /* Make sure that the table is mapped */
    501       1.1    jruoho 
    502       1.6  christos         Status = AcpiTbValidateTable (TableDesc);
    503       1.1    jruoho         if (ACPI_FAILURE (Status))
    504       1.1    jruoho         {
    505       1.1    jruoho             return;
    506       1.1    jruoho         }
    507       1.1    jruoho 
    508       1.1    jruoho         /* Dump the table header */
    509       1.1    jruoho 
    510       1.1    jruoho         if (TableDesc->Pointer)
    511       1.1    jruoho         {
    512       1.1    jruoho             AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
    513       1.1    jruoho         }
    514       1.1    jruoho         else
    515       1.1    jruoho         {
    516       1.1    jruoho             /* If the pointer is null, the table has been unloaded */
    517       1.1    jruoho 
    518      1.10  christos             ACPI_INFO (("%4.4s - Table has been unloaded",
    519       1.1    jruoho                 TableDesc->Signature.Ascii));
    520       1.1    jruoho         }
    521       1.1    jruoho     }
    522       1.1    jruoho }
    523       1.1    jruoho 
    524       1.1    jruoho 
    525       1.1    jruoho /*******************************************************************************
    526       1.1    jruoho  *
    527       1.3    jruoho  * FUNCTION:    AcpiDbUnloadAcpiTable
    528       1.1    jruoho  *
    529       1.4  christos  * PARAMETERS:  ObjectName          - Namespace pathname for an object that
    530       1.4  christos  *                                    is owned by the table to be unloaded
    531       1.1    jruoho  *
    532       1.4  christos  * RETURN:      None
    533       1.1    jruoho  *
    534       1.4  christos  * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned
    535       1.4  christos  *              by the table.
    536       1.1    jruoho  *
    537       1.1    jruoho  ******************************************************************************/
    538       1.1    jruoho 
    539       1.3    jruoho void
    540       1.3    jruoho AcpiDbUnloadAcpiTable (
    541       1.4  christos     char                    *ObjectName)
    542       1.1    jruoho {
    543       1.4  christos     ACPI_NAMESPACE_NODE     *Node;
    544       1.1    jruoho     ACPI_STATUS             Status;
    545       1.1    jruoho 
    546       1.1    jruoho 
    547       1.4  christos     /* Translate name to an Named object */
    548       1.1    jruoho 
    549       1.4  christos     Node = AcpiDbConvertToNode (ObjectName);
    550       1.4  christos     if (!Node)
    551       1.1    jruoho     {
    552       1.4  christos         return;
    553       1.4  christos     }
    554       1.1    jruoho 
    555       1.4  christos     Status = AcpiUnloadParentTable (ACPI_CAST_PTR (ACPI_HANDLE, Node));
    556       1.4  christos     if (ACPI_SUCCESS (Status))
    557       1.4  christos     {
    558       1.4  christos         AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n",
    559       1.4  christos             ObjectName, Node);
    560       1.4  christos     }
    561       1.4  christos     else
    562       1.4  christos     {
    563       1.4  christos         AcpiOsPrintf ("%s, while unloading parent table of [%s]\n",
    564       1.4  christos             AcpiFormatException (Status), ObjectName);
    565       1.1    jruoho     }
    566       1.1    jruoho }
    567       1.1    jruoho 
    568       1.1    jruoho 
    569       1.1    jruoho /*******************************************************************************
    570       1.1    jruoho  *
    571       1.3    jruoho  * FUNCTION:    AcpiDbSendNotify
    572       1.1    jruoho  *
    573       1.4  christos  * PARAMETERS:  Name                - Name of ACPI object where to send notify
    574       1.4  christos  *              Value               - Value of the notify to send.
    575       1.1    jruoho  *
    576       1.1    jruoho  * RETURN:      None
    577       1.1    jruoho  *
    578       1.4  christos  * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
    579       1.3    jruoho  *              named object as an ACPI notify.
    580       1.1    jruoho  *
    581       1.1    jruoho  ******************************************************************************/
    582       1.1    jruoho 
    583       1.3    jruoho void
    584       1.3    jruoho AcpiDbSendNotify (
    585       1.3    jruoho     char                    *Name,
    586       1.3    jruoho     UINT32                  Value)
    587       1.1    jruoho {
    588       1.3    jruoho     ACPI_NAMESPACE_NODE     *Node;
    589       1.3    jruoho     ACPI_STATUS             Status;
    590       1.3    jruoho 
    591       1.1    jruoho 
    592       1.3    jruoho     /* Translate name to an Named object */
    593       1.1    jruoho 
    594       1.3    jruoho     Node = AcpiDbConvertToNode (Name);
    595       1.3    jruoho     if (!Node)
    596       1.1    jruoho     {
    597       1.3    jruoho         return;
    598       1.1    jruoho     }
    599       1.1    jruoho 
    600       1.4  christos     /* Dispatch the notify if legal */
    601       1.1    jruoho 
    602       1.4  christos     if (AcpiEvIsNotifyObject (Node))
    603       1.1    jruoho     {
    604       1.3    jruoho         Status = AcpiEvQueueNotifyRequest (Node, Value);
    605       1.3    jruoho         if (ACPI_FAILURE (Status))
    606       1.3    jruoho         {
    607       1.3    jruoho             AcpiOsPrintf ("Could not queue notify\n");
    608       1.3    jruoho         }
    609       1.4  christos     }
    610       1.4  christos     else
    611       1.4  christos     {
    612       1.4  christos         AcpiOsPrintf (
    613       1.9  christos             "Named object [%4.4s] Type %s, "
    614       1.9  christos             "must be Device/Thermal/Processor type\n",
    615       1.4  christos             AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type));
    616       1.3    jruoho     }
    617       1.1    jruoho }
    618       1.1    jruoho 
    619       1.1    jruoho 
    620       1.1    jruoho /*******************************************************************************
    621       1.1    jruoho  *
    622       1.3    jruoho  * FUNCTION:    AcpiDbDisplayInterfaces
    623       1.1    jruoho  *
    624       1.3    jruoho  * PARAMETERS:  ActionArg           - Null, "install", or "remove"
    625       1.3    jruoho  *              InterfaceNameArg    - Name for install/remove options
    626       1.1    jruoho  *
    627       1.3    jruoho  * RETURN:      None
    628       1.1    jruoho  *
    629       1.3    jruoho  * DESCRIPTION: Display or modify the global _OSI interface list
    630       1.1    jruoho  *
    631       1.1    jruoho  ******************************************************************************/
    632       1.1    jruoho 
    633       1.1    jruoho void
    634       1.3    jruoho AcpiDbDisplayInterfaces (
    635       1.3    jruoho     char                    *ActionArg,
    636       1.3    jruoho     char                    *InterfaceNameArg)
    637       1.1    jruoho {
    638       1.3    jruoho     ACPI_INTERFACE_INFO     *NextInterface;
    639       1.3    jruoho     char                    *SubString;
    640       1.1    jruoho     ACPI_STATUS             Status;
    641       1.1    jruoho 
    642       1.1    jruoho 
    643       1.3    jruoho     /* If no arguments, just display current interface list */
    644       1.3    jruoho 
    645       1.3    jruoho     if (!ActionArg)
    646       1.1    jruoho     {
    647       1.9  christos         (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
    648       1.3    jruoho 
    649       1.3    jruoho         NextInterface = AcpiGbl_SupportedInterfaces;
    650       1.3    jruoho         while (NextInterface)
    651       1.3    jruoho         {
    652       1.3    jruoho             if (!(NextInterface->Flags & ACPI_OSI_INVALID))
    653       1.3    jruoho             {
    654       1.3    jruoho                 AcpiOsPrintf ("%s\n", NextInterface->Name);
    655       1.3    jruoho             }
    656       1.9  christos 
    657       1.3    jruoho             NextInterface = NextInterface->Next;
    658       1.3    jruoho         }
    659       1.3    jruoho 
    660       1.3    jruoho         AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
    661       1.1    jruoho         return;
    662       1.1    jruoho     }
    663       1.1    jruoho 
    664       1.3    jruoho     /* If ActionArg exists, so must InterfaceNameArg */
    665       1.1    jruoho 
    666       1.3    jruoho     if (!InterfaceNameArg)
    667       1.1    jruoho     {
    668       1.3    jruoho         AcpiOsPrintf ("Missing Interface Name argument\n");
    669       1.3    jruoho         return;
    670       1.3    jruoho     }
    671       1.3    jruoho 
    672       1.3    jruoho     /* Uppercase the action for match below */
    673       1.1    jruoho 
    674       1.3    jruoho     AcpiUtStrupr (ActionArg);
    675       1.3    jruoho 
    676       1.3    jruoho     /* Install - install an interface */
    677       1.3    jruoho 
    678       1.8  christos     SubString = strstr ("INSTALL", ActionArg);
    679       1.3    jruoho     if (SubString)
    680       1.3    jruoho     {
    681       1.3    jruoho         Status = AcpiInstallInterface (InterfaceNameArg);
    682       1.1    jruoho         if (ACPI_FAILURE (Status))
    683       1.1    jruoho         {
    684       1.3    jruoho             AcpiOsPrintf ("%s, while installing \"%s\"\n",
    685       1.3    jruoho                 AcpiFormatException (Status), InterfaceNameArg);
    686       1.1    jruoho         }
    687       1.3    jruoho         return;
    688       1.3    jruoho     }
    689       1.3    jruoho 
    690       1.3    jruoho     /* Remove - remove an interface */
    691       1.1    jruoho 
    692       1.8  christos     SubString = strstr ("REMOVE", ActionArg);
    693       1.3    jruoho     if (SubString)
    694       1.1    jruoho     {
    695       1.3    jruoho         Status = AcpiRemoveInterface (InterfaceNameArg);
    696       1.1    jruoho         if (ACPI_FAILURE (Status))
    697       1.1    jruoho         {
    698       1.3    jruoho             AcpiOsPrintf ("%s, while removing \"%s\"\n",
    699       1.3    jruoho                 AcpiFormatException (Status), InterfaceNameArg);
    700       1.1    jruoho         }
    701       1.3    jruoho         return;
    702       1.3    jruoho     }
    703       1.1    jruoho 
    704       1.3    jruoho     /* Invalid ActionArg */
    705       1.1    jruoho 
    706       1.3    jruoho     AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg);
    707       1.1    jruoho     return;
    708       1.1    jruoho }
    709       1.1    jruoho 
    710       1.1    jruoho 
    711       1.1    jruoho /*******************************************************************************
    712       1.1    jruoho  *
    713       1.4  christos  * FUNCTION:    AcpiDbDisplayTemplate
    714       1.4  christos  *
    715       1.4  christos  * PARAMETERS:  BufferArg           - Buffer name or address
    716       1.4  christos  *
    717       1.4  christos  * RETURN:      None
    718       1.4  christos  *
    719       1.4  christos  * DESCRIPTION: Dump a buffer that contains a resource template
    720       1.4  christos  *
    721       1.4  christos  ******************************************************************************/
    722       1.4  christos 
    723       1.4  christos void
    724       1.4  christos AcpiDbDisplayTemplate (
    725       1.4  christos     char                    *BufferArg)
    726       1.4  christos {
    727       1.4  christos     ACPI_NAMESPACE_NODE     *Node;
    728       1.4  christos     ACPI_STATUS             Status;
    729       1.4  christos     ACPI_BUFFER             ReturnBuffer;
    730       1.4  christos 
    731       1.4  christos 
    732       1.4  christos     /* Translate BufferArg to an Named object */
    733       1.4  christos 
    734       1.4  christos     Node = AcpiDbConvertToNode (BufferArg);
    735       1.4  christos     if (!Node || (Node == AcpiGbl_RootNode))
    736       1.4  christos     {
    737       1.4  christos         AcpiOsPrintf ("Invalid argument: %s\n", BufferArg);
    738       1.4  christos         return;
    739       1.4  christos     }
    740       1.4  christos 
    741       1.4  christos     /* We must have a buffer object */
    742       1.4  christos 
    743       1.4  christos     if (Node->Type != ACPI_TYPE_BUFFER)
    744       1.4  christos     {
    745       1.4  christos         AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n",
    746       1.4  christos             BufferArg);
    747       1.4  christos         return;
    748       1.4  christos     }
    749       1.4  christos 
    750       1.4  christos     ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
    751       1.4  christos     ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
    752       1.4  christos 
    753       1.4  christos     /* Attempt to convert the raw buffer to a resource list */
    754       1.4  christos 
    755       1.4  christos     Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer);
    756       1.4  christos 
    757       1.4  christos     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
    758       1.4  christos     AcpiDbgLevel |= ACPI_LV_RESOURCES;
    759       1.4  christos 
    760       1.4  christos     if (ACPI_FAILURE (Status))
    761       1.4  christos     {
    762       1.9  christos         AcpiOsPrintf (
    763       1.9  christos             "Could not convert Buffer to a resource list: %s, %s\n",
    764       1.4  christos             BufferArg, AcpiFormatException (Status));
    765       1.4  christos         goto DumpBuffer;
    766       1.4  christos     }
    767       1.4  christos 
    768       1.4  christos     /* Now we can dump the resource list */
    769       1.4  christos 
    770       1.4  christos     AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
    771       1.4  christos         ReturnBuffer.Pointer));
    772       1.4  christos 
    773       1.4  christos DumpBuffer:
    774       1.4  christos     AcpiOsPrintf ("\nRaw data buffer:\n");
    775       1.4  christos     AcpiUtDebugDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer,
    776       1.4  christos         Node->Object->Buffer.Length,
    777       1.4  christos         DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
    778       1.4  christos 
    779       1.4  christos     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
    780       1.4  christos     return;
    781       1.4  christos }
    782       1.4  christos 
    783       1.4  christos 
    784       1.4  christos /*******************************************************************************
    785       1.4  christos  *
    786       1.1    jruoho  * FUNCTION:    AcpiDmCompareAmlResources
    787       1.1    jruoho  *
    788       1.1    jruoho  * PARAMETERS:  Aml1Buffer          - Contains first resource list
    789       1.1    jruoho  *              Aml1BufferLength    - Length of first resource list
    790       1.1    jruoho  *              Aml2Buffer          - Contains second resource list
    791       1.1    jruoho  *              Aml2BufferLength    - Length of second resource list
    792       1.1    jruoho  *
    793       1.1    jruoho  * RETURN:      None
    794       1.1    jruoho  *
    795       1.1    jruoho  * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
    796       1.1    jruoho  *              order to isolate a miscompare to an individual resource)
    797       1.1    jruoho  *
    798       1.1    jruoho  ******************************************************************************/
    799       1.1    jruoho 
    800       1.1    jruoho static void
    801       1.1    jruoho AcpiDmCompareAmlResources (
    802       1.1    jruoho     UINT8                   *Aml1Buffer,
    803       1.1    jruoho     ACPI_RSDESC_SIZE        Aml1BufferLength,
    804       1.1    jruoho     UINT8                   *Aml2Buffer,
    805       1.1    jruoho     ACPI_RSDESC_SIZE        Aml2BufferLength)
    806       1.1    jruoho {
    807       1.1    jruoho     UINT8                   *Aml1;
    808       1.1    jruoho     UINT8                   *Aml2;
    809       1.4  christos     UINT8                   *Aml1End;
    810       1.4  christos     UINT8                   *Aml2End;
    811       1.1    jruoho     ACPI_RSDESC_SIZE        Aml1Length;
    812       1.1    jruoho     ACPI_RSDESC_SIZE        Aml2Length;
    813       1.1    jruoho     ACPI_RSDESC_SIZE        Offset = 0;
    814       1.1    jruoho     UINT8                   ResourceType;
    815       1.1    jruoho     UINT32                  Count = 0;
    816       1.4  christos     UINT32                  i;
    817       1.1    jruoho 
    818       1.1    jruoho 
    819       1.1    jruoho     /* Compare overall buffer sizes (may be different due to size rounding) */
    820       1.1    jruoho 
    821       1.1    jruoho     if (Aml1BufferLength != Aml2BufferLength)
    822       1.1    jruoho     {
    823       1.1    jruoho         AcpiOsPrintf (
    824       1.9  christos             "**** Buffer length mismatch in converted "
    825       1.9  christos             "AML: Original %X, New %X ****\n",
    826       1.1    jruoho             Aml1BufferLength, Aml2BufferLength);
    827       1.1    jruoho     }
    828       1.1    jruoho 
    829       1.1    jruoho     Aml1 = Aml1Buffer;
    830       1.1    jruoho     Aml2 = Aml2Buffer;
    831       1.4  christos     Aml1End = Aml1Buffer + Aml1BufferLength;
    832       1.4  christos     Aml2End = Aml2Buffer + Aml2BufferLength;
    833       1.1    jruoho 
    834       1.1    jruoho     /* Walk the descriptor lists, comparing each descriptor */
    835       1.1    jruoho 
    836       1.4  christos     while ((Aml1 < Aml1End) && (Aml2 < Aml2End))
    837       1.1    jruoho     {
    838       1.1    jruoho         /* Get the lengths of each descriptor */
    839       1.1    jruoho 
    840       1.1    jruoho         Aml1Length = AcpiUtGetDescriptorLength (Aml1);
    841       1.1    jruoho         Aml2Length = AcpiUtGetDescriptorLength (Aml2);
    842       1.1    jruoho         ResourceType = AcpiUtGetResourceType (Aml1);
    843       1.1    jruoho 
    844       1.1    jruoho         /* Check for descriptor length match */
    845       1.1    jruoho 
    846       1.1    jruoho         if (Aml1Length != Aml2Length)
    847       1.1    jruoho         {
    848       1.1    jruoho             AcpiOsPrintf (
    849       1.9  christos                 "**** Length mismatch in descriptor [%.2X] type %2.2X, "
    850       1.9  christos                 "Offset %8.8X Len1 %X, Len2 %X ****\n",
    851       1.1    jruoho                 Count, ResourceType, Offset, Aml1Length, Aml2Length);
    852       1.1    jruoho         }
    853       1.1    jruoho 
    854       1.1    jruoho         /* Check for descriptor byte match */
    855       1.1    jruoho 
    856       1.8  christos         else if (memcmp (Aml1, Aml2, Aml1Length))
    857       1.1    jruoho         {
    858       1.1    jruoho             AcpiOsPrintf (
    859       1.9  christos                 "**** Data mismatch in descriptor [%.2X] type %2.2X, "
    860       1.9  christos                 "Offset %8.8X ****\n",
    861       1.1    jruoho                 Count, ResourceType, Offset);
    862       1.4  christos 
    863       1.4  christos             for (i = 0; i < Aml1Length; i++)
    864       1.4  christos             {
    865       1.4  christos                 if (Aml1[i] != Aml2[i])
    866       1.4  christos                 {
    867       1.4  christos                     AcpiOsPrintf (
    868       1.9  christos                         "Mismatch at byte offset %.2X: is %2.2X, "
    869       1.9  christos                         "should be %2.2X\n",
    870       1.4  christos                         i, Aml2[i], Aml1[i]);
    871       1.4  christos                 }
    872       1.4  christos             }
    873       1.1    jruoho         }
    874       1.1    jruoho 
    875       1.1    jruoho         /* Exit on EndTag descriptor */
    876       1.1    jruoho 
    877       1.1    jruoho         if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
    878       1.1    jruoho         {
    879       1.1    jruoho             return;
    880       1.1    jruoho         }
    881       1.1    jruoho 
    882       1.1    jruoho         /* Point to next descriptor in each buffer */
    883       1.1    jruoho 
    884       1.1    jruoho         Count++;
    885       1.1    jruoho         Offset += Aml1Length;
    886       1.1    jruoho         Aml1 += Aml1Length;
    887       1.1    jruoho         Aml2 += Aml2Length;
    888       1.1    jruoho     }
    889       1.1    jruoho }
    890       1.1    jruoho 
    891       1.1    jruoho 
    892       1.1    jruoho /*******************************************************************************
    893       1.1    jruoho  *
    894       1.1    jruoho  * FUNCTION:    AcpiDmTestResourceConversion
    895       1.1    jruoho  *
    896       1.4  christos  * PARAMETERS:  Node                - Parent device node
    897       1.4  christos  *              Name                - resource method name (_CRS)
    898       1.1    jruoho  *
    899       1.1    jruoho  * RETURN:      Status
    900       1.1    jruoho  *
    901       1.1    jruoho  * DESCRIPTION: Compare the original AML with a conversion of the AML to
    902       1.1    jruoho  *              internal resource list, then back to AML.
    903       1.1    jruoho  *
    904       1.1    jruoho  ******************************************************************************/
    905       1.1    jruoho 
    906       1.1    jruoho static ACPI_STATUS
    907       1.1    jruoho AcpiDmTestResourceConversion (
    908       1.1    jruoho     ACPI_NAMESPACE_NODE     *Node,
    909       1.1    jruoho     char                    *Name)
    910       1.1    jruoho {
    911       1.1    jruoho     ACPI_STATUS             Status;
    912       1.4  christos     ACPI_BUFFER             ReturnBuffer;
    913       1.4  christos     ACPI_BUFFER             ResourceBuffer;
    914       1.1    jruoho     ACPI_BUFFER             NewAml;
    915       1.1    jruoho     ACPI_OBJECT             *OriginalAml;
    916       1.1    jruoho 
    917       1.1    jruoho 
    918       1.1    jruoho     AcpiOsPrintf ("Resource Conversion Comparison:\n");
    919       1.1    jruoho 
    920       1.1    jruoho     NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
    921       1.4  christos     ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
    922       1.4  christos     ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
    923       1.1    jruoho 
    924       1.1    jruoho     /* Get the original _CRS AML resource template */
    925       1.1    jruoho 
    926       1.4  christos     Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer);
    927       1.1    jruoho     if (ACPI_FAILURE (Status))
    928       1.1    jruoho     {
    929       1.1    jruoho         AcpiOsPrintf ("Could not obtain %s: %s\n",
    930       1.1    jruoho             Name, AcpiFormatException (Status));
    931       1.1    jruoho         return (Status);
    932       1.1    jruoho     }
    933       1.1    jruoho 
    934       1.1    jruoho     /* Get the AML resource template, converted to internal resource structs */
    935       1.1    jruoho 
    936       1.4  christos     Status = AcpiGetCurrentResources (Node, &ResourceBuffer);
    937       1.1    jruoho     if (ACPI_FAILURE (Status))
    938       1.1    jruoho     {
    939       1.1    jruoho         AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
    940       1.1    jruoho             AcpiFormatException (Status));
    941       1.1    jruoho         goto Exit1;
    942       1.1    jruoho     }
    943       1.1    jruoho 
    944       1.1    jruoho     /* Convert internal resource list to external AML resource template */
    945       1.1    jruoho 
    946       1.4  christos     Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml);
    947       1.1    jruoho     if (ACPI_FAILURE (Status))
    948       1.1    jruoho     {
    949       1.1    jruoho         AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
    950       1.1    jruoho             AcpiFormatException (Status));
    951       1.1    jruoho         goto Exit2;
    952       1.1    jruoho     }
    953       1.1    jruoho 
    954       1.1    jruoho     /* Compare original AML to the newly created AML resource list */
    955       1.1    jruoho 
    956       1.4  christos     OriginalAml = ReturnBuffer.Pointer;
    957       1.1    jruoho 
    958       1.4  christos     AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer,
    959       1.4  christos         (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
    960       1.1    jruoho         NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
    961       1.1    jruoho 
    962       1.1    jruoho     /* Cleanup and exit */
    963       1.1    jruoho 
    964       1.1    jruoho     ACPI_FREE (NewAml.Pointer);
    965       1.1    jruoho Exit2:
    966       1.4  christos     ACPI_FREE (ResourceBuffer.Pointer);
    967       1.1    jruoho Exit1:
    968       1.4  christos     ACPI_FREE (ReturnBuffer.Pointer);
    969       1.1    jruoho     return (Status);
    970       1.1    jruoho }
    971       1.1    jruoho 
    972       1.1    jruoho 
    973       1.1    jruoho /*******************************************************************************
    974       1.1    jruoho  *
    975       1.4  christos  * FUNCTION:    AcpiDbResourceCallback
    976       1.4  christos  *
    977       1.4  christos  * PARAMETERS:  ACPI_WALK_RESOURCE_CALLBACK
    978       1.4  christos  *
    979       1.4  christos  * RETURN:      Status
    980       1.4  christos  *
    981       1.4  christos  * DESCRIPTION: Simple callback to exercise AcpiWalkResources and
    982       1.4  christos  *              AcpiWalkResourceBuffer.
    983       1.4  christos  *
    984       1.4  christos  ******************************************************************************/
    985       1.4  christos 
    986       1.4  christos static ACPI_STATUS
    987       1.4  christos AcpiDbResourceCallback (
    988       1.4  christos     ACPI_RESOURCE           *Resource,
    989       1.4  christos     void                    *Context)
    990       1.4  christos {
    991       1.4  christos 
    992       1.4  christos     return (AE_OK);
    993       1.4  christos }
    994       1.4  christos 
    995       1.4  christos 
    996       1.4  christos /*******************************************************************************
    997       1.4  christos  *
    998       1.4  christos  * FUNCTION:    AcpiDbDeviceResources
    999       1.1    jruoho  *
   1000       1.4  christos  * PARAMETERS:  ACPI_WALK_CALLBACK
   1001       1.1    jruoho  *
   1002       1.4  christos  * RETURN:      Status
   1003       1.1    jruoho  *
   1004       1.4  christos  * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
   1005       1.1    jruoho  *
   1006       1.1    jruoho  ******************************************************************************/
   1007       1.1    jruoho 
   1008       1.4  christos static ACPI_STATUS
   1009       1.4  christos AcpiDbDeviceResources (
   1010       1.4  christos     ACPI_HANDLE             ObjHandle,
   1011       1.4  christos     UINT32                  NestingLevel,
   1012       1.4  christos     void                    *Context,
   1013       1.4  christos     void                    **ReturnValue)
   1014       1.1    jruoho {
   1015       1.1    jruoho     ACPI_NAMESPACE_NODE     *Node;
   1016       1.4  christos     ACPI_NAMESPACE_NODE     *PrtNode = NULL;
   1017       1.4  christos     ACPI_NAMESPACE_NODE     *CrsNode = NULL;
   1018       1.4  christos     ACPI_NAMESPACE_NODE     *PrsNode = NULL;
   1019       1.4  christos     ACPI_NAMESPACE_NODE     *AeiNode = NULL;
   1020       1.4  christos     char                    *ParentPath;
   1021       1.4  christos     ACPI_BUFFER             ReturnBuffer;
   1022       1.1    jruoho     ACPI_STATUS             Status;
   1023       1.1    jruoho 
   1024       1.1    jruoho 
   1025       1.4  christos     Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
   1026       1.9  christos     ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE);
   1027       1.4  christos     if (!ParentPath)
   1028       1.4  christos     {
   1029       1.4  christos         return (AE_NO_MEMORY);
   1030       1.4  christos     }
   1031       1.1    jruoho 
   1032       1.4  christos     /* Get handles to the resource methods for this device */
   1033       1.1    jruoho 
   1034       1.9  christos     (void) AcpiGetHandle (Node, METHOD_NAME__PRT,
   1035       1.9  christos         ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode));
   1036       1.9  christos     (void) AcpiGetHandle (Node, METHOD_NAME__CRS,
   1037       1.9  christos         ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode));
   1038       1.9  christos     (void) AcpiGetHandle (Node, METHOD_NAME__PRS,
   1039       1.9  christos         ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode));
   1040       1.9  christos     (void) AcpiGetHandle (Node, METHOD_NAME__AEI,
   1041       1.9  christos         ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode));
   1042       1.9  christos 
   1043       1.4  christos     if (!PrtNode && !CrsNode && !PrsNode && !AeiNode)
   1044       1.1    jruoho     {
   1045       1.4  christos         goto Cleanup;   /* Nothing to do */
   1046       1.1    jruoho     }
   1047       1.1    jruoho 
   1048       1.4  christos     AcpiOsPrintf ("\nDevice: %s\n", ParentPath);
   1049       1.4  christos 
   1050       1.1    jruoho     /* Prepare for a return object of arbitrary size */
   1051       1.1    jruoho 
   1052       1.4  christos     ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
   1053       1.4  christos     ReturnBuffer.Length  = ACPI_DEBUG_BUFFER_SIZE;
   1054       1.4  christos 
   1055       1.1    jruoho 
   1056       1.1    jruoho     /* _PRT */
   1057       1.1    jruoho 
   1058       1.4  christos     if (PrtNode)
   1059       1.4  christos     {
   1060       1.4  christos         AcpiOsPrintf ("Evaluating _PRT\n");
   1061       1.4  christos 
   1062       1.4  christos         Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer);
   1063       1.4  christos         if (ACPI_FAILURE (Status))
   1064       1.4  christos         {
   1065       1.4  christos             AcpiOsPrintf ("Could not evaluate _PRT: %s\n",
   1066       1.4  christos                 AcpiFormatException (Status));
   1067       1.4  christos             goto GetCrs;
   1068       1.4  christos         }
   1069       1.1    jruoho 
   1070       1.4  christos         ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
   1071       1.4  christos         ReturnBuffer.Length  = ACPI_DEBUG_BUFFER_SIZE;
   1072       1.4  christos 
   1073       1.4  christos         Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer);
   1074       1.4  christos         if (ACPI_FAILURE (Status))
   1075       1.4  christos         {
   1076       1.4  christos             AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
   1077       1.4  christos                 AcpiFormatException (Status));
   1078       1.4  christos             goto GetCrs;
   1079       1.4  christos         }
   1080       1.1    jruoho 
   1081       1.4  christos         AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
   1082       1.1    jruoho     }
   1083       1.1    jruoho 
   1084       1.1    jruoho 
   1085       1.4  christos     /* _CRS */
   1086       1.4  christos 
   1087       1.4  christos GetCrs:
   1088       1.4  christos     if (CrsNode)
   1089       1.1    jruoho     {
   1090       1.4  christos         AcpiOsPrintf ("Evaluating _CRS\n");
   1091       1.1    jruoho 
   1092       1.4  christos         ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
   1093       1.4  christos         ReturnBuffer.Length  = ACPI_DEBUG_BUFFER_SIZE;
   1094       1.1    jruoho 
   1095       1.4  christos         Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer);
   1096       1.4  christos         if (ACPI_FAILURE (Status))
   1097       1.4  christos         {
   1098       1.4  christos             AcpiOsPrintf ("Could not evaluate _CRS: %s\n",
   1099       1.4  christos                 AcpiFormatException (Status));
   1100       1.4  christos             goto GetPrs;
   1101       1.4  christos         }
   1102       1.1    jruoho 
   1103       1.4  christos         /* This code exercises the AcpiWalkResources interface */
   1104       1.1    jruoho 
   1105       1.4  christos         Status = AcpiWalkResources (Node, METHOD_NAME__CRS,
   1106       1.4  christos             AcpiDbResourceCallback, NULL);
   1107       1.4  christos         if (ACPI_FAILURE (Status))
   1108       1.4  christos         {
   1109       1.4  christos             AcpiOsPrintf ("AcpiWalkResources failed: %s\n",
   1110       1.4  christos                 AcpiFormatException (Status));
   1111       1.4  christos             goto GetPrs;
   1112       1.4  christos         }
   1113       1.1    jruoho 
   1114       1.4  christos         /* Get the _CRS resource list (test ALLOCATE buffer) */
   1115       1.1    jruoho 
   1116       1.4  christos         ReturnBuffer.Pointer = NULL;
   1117       1.9  christos         ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
   1118       1.1    jruoho 
   1119       1.4  christos         Status = AcpiGetCurrentResources (Node, &ReturnBuffer);
   1120       1.4  christos         if (ACPI_FAILURE (Status))
   1121       1.4  christos         {
   1122       1.4  christos             AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
   1123       1.4  christos                 AcpiFormatException (Status));
   1124       1.4  christos             goto GetPrs;
   1125       1.4  christos         }
   1126       1.1    jruoho 
   1127       1.4  christos         /* This code exercises the AcpiWalkResourceBuffer interface */
   1128       1.1    jruoho 
   1129       1.4  christos         Status = AcpiWalkResourceBuffer (&ReturnBuffer,
   1130       1.4  christos             AcpiDbResourceCallback, NULL);
   1131       1.4  christos         if (ACPI_FAILURE (Status))
   1132       1.4  christos         {
   1133       1.4  christos             AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n",
   1134       1.4  christos                 AcpiFormatException (Status));
   1135       1.4  christos             goto EndCrs;
   1136       1.4  christos         }
   1137       1.1    jruoho 
   1138       1.4  christos         /* Dump the _CRS resource list */
   1139       1.1    jruoho 
   1140       1.4  christos         AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
   1141       1.4  christos             ReturnBuffer.Pointer));
   1142       1.1    jruoho 
   1143       1.4  christos         /*
   1144       1.4  christos          * Perform comparison of original AML to newly created AML. This
   1145       1.4  christos          * tests both the AML->Resource conversion and the Resource->AML
   1146       1.4  christos          * conversion.
   1147       1.4  christos          */
   1148       1.5  christos         (void) AcpiDmTestResourceConversion (Node, __UNCONST(METHOD_NAME__CRS));
   1149       1.4  christos 
   1150       1.4  christos         /* Execute _SRS with the resource list */
   1151       1.1    jruoho 
   1152       1.4  christos         AcpiOsPrintf ("Evaluating _SRS\n");
   1153       1.1    jruoho 
   1154       1.4  christos         Status = AcpiSetCurrentResources (Node, &ReturnBuffer);
   1155       1.4  christos         if (ACPI_FAILURE (Status))
   1156       1.4  christos         {
   1157       1.4  christos             AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
   1158       1.4  christos                 AcpiFormatException (Status));
   1159       1.4  christos             goto EndCrs;
   1160       1.4  christos         }
   1161       1.1    jruoho 
   1162       1.4  christos EndCrs:
   1163       1.4  christos         ACPI_FREE (ReturnBuffer.Pointer);
   1164       1.1    jruoho     }
   1165       1.1    jruoho 
   1166       1.1    jruoho 
   1167       1.1    jruoho     /* _PRS */
   1168       1.1    jruoho 
   1169       1.1    jruoho GetPrs:
   1170       1.4  christos     if (PrsNode)
   1171       1.4  christos     {
   1172       1.4  christos         AcpiOsPrintf ("Evaluating _PRS\n");
   1173       1.4  christos 
   1174       1.4  christos         ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
   1175       1.4  christos         ReturnBuffer.Length  = ACPI_DEBUG_BUFFER_SIZE;
   1176       1.1    jruoho 
   1177       1.4  christos         Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer);
   1178       1.4  christos         if (ACPI_FAILURE (Status))
   1179       1.4  christos         {
   1180       1.4  christos             AcpiOsPrintf ("Could not evaluate _PRS: %s\n",
   1181       1.4  christos                 AcpiFormatException (Status));
   1182       1.4  christos             goto GetAei;
   1183       1.4  christos         }
   1184       1.1    jruoho 
   1185       1.4  christos         ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
   1186       1.9  christos         ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
   1187       1.4  christos 
   1188       1.4  christos         Status = AcpiGetPossibleResources (Node, &ReturnBuffer);
   1189       1.4  christos         if (ACPI_FAILURE (Status))
   1190       1.4  christos         {
   1191       1.4  christos             AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
   1192       1.4  christos                 AcpiFormatException (Status));
   1193       1.4  christos             goto GetAei;
   1194       1.4  christos         }
   1195       1.1    jruoho 
   1196       1.9  christos         AcpiRsDumpResourceList (ACPI_CAST_PTR (
   1197       1.9  christos             ACPI_RESOURCE, AcpiGbl_DbBuffer));
   1198       1.1    jruoho     }
   1199       1.1    jruoho 
   1200       1.1    jruoho 
   1201       1.4  christos     /* _AEI */
   1202       1.4  christos 
   1203       1.4  christos GetAei:
   1204       1.4  christos     if (AeiNode)
   1205       1.1    jruoho     {
   1206       1.4  christos         AcpiOsPrintf ("Evaluating _AEI\n");
   1207       1.4  christos 
   1208       1.4  christos         ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
   1209       1.9  christos         ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
   1210       1.4  christos 
   1211       1.4  christos         Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer);
   1212       1.4  christos         if (ACPI_FAILURE (Status))
   1213       1.4  christos         {
   1214       1.4  christos             AcpiOsPrintf ("Could not evaluate _AEI: %s\n",
   1215       1.4  christos                 AcpiFormatException (Status));
   1216       1.4  christos             goto Cleanup;
   1217       1.4  christos         }
   1218       1.4  christos 
   1219       1.4  christos         ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
   1220       1.9  christos         ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
   1221       1.4  christos 
   1222       1.4  christos         Status = AcpiGetEventResources (Node, &ReturnBuffer);
   1223       1.4  christos         if (ACPI_FAILURE (Status))
   1224       1.4  christos         {
   1225       1.4  christos             AcpiOsPrintf ("AcpiGetEventResources failed: %s\n",
   1226       1.4  christos                 AcpiFormatException (Status));
   1227       1.4  christos             goto Cleanup;
   1228       1.4  christos         }
   1229       1.4  christos 
   1230       1.9  christos         AcpiRsDumpResourceList (ACPI_CAST_PTR (
   1231       1.9  christos             ACPI_RESOURCE, AcpiGbl_DbBuffer));
   1232       1.1    jruoho     }
   1233       1.1    jruoho 
   1234       1.1    jruoho 
   1235       1.1    jruoho Cleanup:
   1236       1.4  christos     ACPI_FREE (ParentPath);
   1237       1.4  christos     return (AE_OK);
   1238       1.4  christos }
   1239       1.4  christos 
   1240       1.4  christos 
   1241       1.4  christos /*******************************************************************************
   1242       1.4  christos  *
   1243       1.4  christos  * FUNCTION:    AcpiDbDisplayResources
   1244       1.4  christos  *
   1245       1.4  christos  * PARAMETERS:  ObjectArg           - String object name or object pointer.
   1246       1.4  christos  *                                    NULL or "*" means "display resources for
   1247       1.4  christos  *                                    all devices"
   1248       1.4  christos  *
   1249       1.4  christos  * RETURN:      None
   1250       1.4  christos  *
   1251       1.4  christos  * DESCRIPTION: Display the resource objects associated with a device.
   1252       1.4  christos  *
   1253       1.4  christos  ******************************************************************************/
   1254       1.4  christos 
   1255       1.4  christos void
   1256       1.4  christos AcpiDbDisplayResources (
   1257       1.4  christos     char                    *ObjectArg)
   1258       1.4  christos {
   1259       1.4  christos     ACPI_NAMESPACE_NODE     *Node;
   1260       1.4  christos 
   1261       1.4  christos 
   1262       1.4  christos     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
   1263       1.4  christos     AcpiDbgLevel |= ACPI_LV_RESOURCES;
   1264       1.4  christos 
   1265       1.4  christos     /* Asterisk means "display resources for all devices" */
   1266       1.4  christos 
   1267       1.8  christos     if (!ObjectArg || (!strcmp (ObjectArg, "*")))
   1268       1.4  christos     {
   1269       1.4  christos         (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
   1270       1.9  christos             ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL);
   1271       1.4  christos     }
   1272       1.4  christos     else
   1273       1.4  christos     {
   1274       1.4  christos         /* Convert string to object pointer */
   1275       1.4  christos 
   1276       1.4  christos         Node = AcpiDbConvertToNode (ObjectArg);
   1277       1.4  christos         if (Node)
   1278       1.4  christos         {
   1279       1.4  christos             if (Node->Type != ACPI_TYPE_DEVICE)
   1280       1.4  christos             {
   1281       1.9  christos                 AcpiOsPrintf (
   1282       1.9  christos                     "%4.4s: Name is not a device object (%s)\n",
   1283       1.4  christos                     Node->Name.Ascii, AcpiUtGetTypeName (Node->Type));
   1284       1.4  christos             }
   1285       1.4  christos             else
   1286       1.4  christos             {
   1287       1.4  christos                 (void) AcpiDbDeviceResources (Node, 0, NULL, NULL);
   1288       1.4  christos             }
   1289       1.4  christos         }
   1290       1.4  christos     }
   1291       1.1    jruoho 
   1292       1.1    jruoho     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
   1293       1.1    jruoho }
   1294       1.1    jruoho 
   1295       1.1    jruoho 
   1296      1.17  christos /*******************************************************************************
   1297      1.17  christos  *
   1298      1.17  christos  * FUNCTION:    AcpiDbGenerateGed
   1299      1.17  christos  *
   1300      1.17  christos  * PARAMETERS:  GedArg              - Raw GED number, ascii string
   1301      1.17  christos  *
   1302      1.17  christos  * RETURN:      None
   1303      1.17  christos  *
   1304      1.17  christos  * DESCRIPTION: Simulate firing of a GED
   1305      1.17  christos  *
   1306      1.17  christos  ******************************************************************************/
   1307      1.17  christos 
   1308      1.17  christos void
   1309      1.17  christos AcpiDbGenerateInterrupt (
   1310      1.17  christos     char *GsivArg)
   1311      1.17  christos {
   1312      1.17  christos     UINT32      GsivNumber;
   1313      1.17  christos     ACPI_GED_HANDLER_INFO *GedInfo = AcpiGbl_GedHandlerList;
   1314      1.17  christos 
   1315      1.17  christos 	if (!GedInfo) {
   1316      1.17  christos 		AcpiOsPrintf ("No GED handling present\n");
   1317      1.17  christos 	}
   1318      1.17  christos 
   1319      1.17  christos     GsivNumber = strtoul (GsivArg, NULL, 0);
   1320      1.17  christos 
   1321      1.17  christos 	while (GedInfo) {
   1322      1.17  christos 
   1323      1.17  christos 		if (GedInfo->IntId == GsivNumber) {
   1324      1.17  christos 			ACPI_OBJECT_LIST ArgList;
   1325      1.17  christos 			ACPI_OBJECT Arg0;
   1326      1.17  christos 			ACPI_HANDLE EvtHandle = GedInfo->EvtMethod;
   1327      1.17  christos 			ACPI_STATUS Status;
   1328      1.17  christos 
   1329      1.17  christos 			AcpiOsPrintf ("Evaluate GED _EVT (GSIV=%d)\n", GsivNumber);
   1330      1.17  christos 
   1331      1.17  christos 			if (!EvtHandle) {
   1332      1.17  christos 				AcpiOsPrintf ("Undefined _EVT method\n");
   1333      1.17  christos 				return;
   1334      1.17  christos 			}
   1335      1.17  christos 
   1336      1.17  christos 			Arg0.Integer.Type = ACPI_TYPE_INTEGER;
   1337      1.17  christos 			Arg0.Integer.Value = GsivNumber;
   1338      1.17  christos 
   1339      1.17  christos 			ArgList.Count = 1;
   1340      1.17  christos 			ArgList.Pointer = &Arg0;
   1341      1.17  christos 
   1342      1.17  christos 			Status = AcpiEvaluateObject (EvtHandle, NULL, &ArgList, NULL);
   1343      1.17  christos 			if (ACPI_FAILURE (Status))
   1344      1.17  christos 			{
   1345      1.17  christos 				AcpiOsPrintf ("Could not evaluate _EVT\n");
   1346      1.17  christos 				return;
   1347      1.17  christos 			}
   1348      1.17  christos 
   1349      1.17  christos 		}
   1350      1.17  christos 		GedInfo = GedInfo->Next;
   1351      1.17  christos 	}
   1352      1.17  christos }
   1353      1.17  christos 
   1354       1.4  christos #if (!ACPI_REDUCED_HARDWARE)
   1355       1.1    jruoho /*******************************************************************************
   1356       1.1    jruoho  *
   1357       1.1    jruoho  * FUNCTION:    AcpiDbGenerateGpe
   1358       1.1    jruoho  *
   1359       1.4  christos  * PARAMETERS:  GpeArg              - Raw GPE number, ascii string
   1360       1.4  christos  *              BlockArg            - GPE block number, ascii string
   1361       1.4  christos  *                                    0 or 1 for FADT GPE blocks
   1362       1.1    jruoho  *
   1363       1.1    jruoho  * RETURN:      None
   1364       1.1    jruoho  *
   1365       1.4  christos  * DESCRIPTION: Simulate firing of a GPE
   1366       1.1    jruoho  *
   1367       1.1    jruoho  ******************************************************************************/
   1368       1.1    jruoho 
   1369       1.1    jruoho void
   1370       1.1    jruoho AcpiDbGenerateGpe (
   1371       1.1    jruoho     char                    *GpeArg,
   1372       1.1    jruoho     char                    *BlockArg)
   1373       1.1    jruoho {
   1374       1.6  christos     UINT32                  BlockNumber = 0;
   1375       1.1    jruoho     UINT32                  GpeNumber;
   1376       1.1    jruoho     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
   1377       1.1    jruoho 
   1378       1.1    jruoho 
   1379       1.8  christos     GpeNumber = strtoul (GpeArg, NULL, 0);
   1380       1.1    jruoho 
   1381       1.6  christos     /*
   1382       1.6  christos      * If no block arg, or block arg == 0 or 1, use the FADT-defined
   1383       1.6  christos      * GPE blocks.
   1384       1.6  christos      */
   1385       1.6  christos     if (BlockArg)
   1386       1.6  christos     {
   1387       1.8  christos         BlockNumber = strtoul (BlockArg, NULL, 0);
   1388       1.6  christos         if (BlockNumber == 1)
   1389       1.6  christos         {
   1390       1.6  christos             BlockNumber = 0;
   1391       1.6  christos         }
   1392       1.6  christos     }
   1393       1.1    jruoho 
   1394       1.9  christos     GpeEventInfo = AcpiEvGetGpeEventInfo (
   1395       1.9  christos         ACPI_TO_POINTER (BlockNumber), GpeNumber);
   1396       1.1    jruoho     if (!GpeEventInfo)
   1397       1.1    jruoho     {
   1398       1.1    jruoho         AcpiOsPrintf ("Invalid GPE\n");
   1399       1.1    jruoho         return;
   1400       1.1    jruoho     }
   1401       1.1    jruoho 
   1402       1.3    jruoho     (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber);
   1403       1.1    jruoho }
   1404       1.1    jruoho 
   1405       1.9  christos 
   1406       1.9  christos /*******************************************************************************
   1407       1.9  christos  *
   1408       1.9  christos  * FUNCTION:    AcpiDbGenerateSci
   1409       1.9  christos  *
   1410       1.9  christos  * PARAMETERS:  None
   1411       1.9  christos  *
   1412       1.9  christos  * RETURN:      None
   1413       1.9  christos  *
   1414       1.9  christos  * DESCRIPTION: Simulate an SCI -- just call the SCI dispatch.
   1415       1.9  christos  *
   1416       1.9  christos  ******************************************************************************/
   1417       1.9  christos 
   1418       1.4  christos void
   1419       1.4  christos AcpiDbGenerateSci (
   1420       1.4  christos     void)
   1421       1.4  christos {
   1422       1.4  christos     AcpiEvSciDispatch ();
   1423       1.4  christos }
   1424       1.4  christos 
   1425       1.4  christos #endif /* !ACPI_REDUCED_HARDWARE */
   1426       1.4  christos 
   1427       1.8  christos 
   1428       1.8  christos /*******************************************************************************
   1429       1.8  christos  *
   1430       1.8  christos  * FUNCTION:    AcpiDbTrace
   1431       1.8  christos  *
   1432       1.8  christos  * PARAMETERS:  EnableArg           - ENABLE/AML to enable tracer
   1433       1.8  christos  *                                    DISABLE to disable tracer
   1434       1.8  christos  *              MethodArg           - Method to trace
   1435       1.8  christos  *              OnceArg             - Whether trace once
   1436       1.8  christos  *
   1437       1.8  christos  * RETURN:      None
   1438       1.8  christos  *
   1439       1.8  christos  * DESCRIPTION: Control method tracing facility
   1440       1.8  christos  *
   1441       1.8  christos  ******************************************************************************/
   1442       1.8  christos 
   1443       1.8  christos void
   1444       1.8  christos AcpiDbTrace (
   1445       1.8  christos     char                    *EnableArg,
   1446       1.8  christos     char                    *MethodArg,
   1447       1.8  christos     char                    *OnceArg)
   1448       1.8  christos {
   1449       1.8  christos     UINT32                  DebugLevel = 0;
   1450       1.8  christos     UINT32                  DebugLayer = 0;
   1451       1.8  christos     UINT32                  Flags = 0;
   1452       1.8  christos 
   1453       1.8  christos 
   1454       1.9  christos     AcpiUtStrupr (EnableArg);
   1455       1.9  christos     AcpiUtStrupr (OnceArg);
   1456       1.9  christos 
   1457       1.8  christos     if (MethodArg)
   1458       1.8  christos     {
   1459       1.8  christos         if (AcpiDbTraceMethodName)
   1460       1.8  christos         {
   1461       1.8  christos             ACPI_FREE (AcpiDbTraceMethodName);
   1462       1.8  christos             AcpiDbTraceMethodName = NULL;
   1463       1.8  christos         }
   1464       1.9  christos 
   1465       1.8  christos         AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1);
   1466       1.8  christos         if (!AcpiDbTraceMethodName)
   1467       1.8  christos         {
   1468       1.9  christos             AcpiOsPrintf ("Failed to allocate method name (%s)\n",
   1469       1.9  christos                 MethodArg);
   1470       1.8  christos             return;
   1471       1.8  christos         }
   1472       1.9  christos 
   1473       1.8  christos         strcpy (AcpiDbTraceMethodName, MethodArg);
   1474       1.8  christos     }
   1475       1.9  christos 
   1476       1.8  christos     if (!strcmp (EnableArg, "ENABLE") ||
   1477       1.8  christos         !strcmp (EnableArg, "METHOD") ||
   1478       1.8  christos         !strcmp (EnableArg, "OPCODE"))
   1479       1.8  christos     {
   1480       1.8  christos         if (!strcmp (EnableArg, "ENABLE"))
   1481       1.8  christos         {
   1482       1.8  christos             /* Inherit current console settings */
   1483       1.8  christos 
   1484       1.8  christos             DebugLevel = AcpiGbl_DbConsoleDebugLevel;
   1485       1.8  christos             DebugLayer = AcpiDbgLayer;
   1486       1.8  christos         }
   1487       1.8  christos         else
   1488       1.8  christos         {
   1489       1.8  christos             /* Restrict console output to trace points only */
   1490       1.8  christos 
   1491       1.8  christos             DebugLevel = ACPI_LV_TRACE_POINT;
   1492       1.8  christos             DebugLayer = ACPI_EXECUTER;
   1493       1.8  christos         }
   1494       1.8  christos 
   1495       1.8  christos         Flags = ACPI_TRACE_ENABLED;
   1496       1.9  christos 
   1497       1.8  christos         if (!strcmp (EnableArg, "OPCODE"))
   1498       1.8  christos         {
   1499       1.8  christos             Flags |= ACPI_TRACE_OPCODE;
   1500       1.8  christos         }
   1501       1.9  christos 
   1502       1.8  christos         if (OnceArg && !strcmp (OnceArg, "ONCE"))
   1503       1.8  christos         {
   1504       1.8  christos             Flags |= ACPI_TRACE_ONESHOT;
   1505       1.8  christos         }
   1506       1.8  christos     }
   1507       1.8  christos 
   1508       1.8  christos     (void) AcpiDebugTrace (AcpiDbTraceMethodName,
   1509       1.9  christos         DebugLevel, DebugLayer, Flags);
   1510       1.8  christos }
   1511