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