Home | History | Annotate | Line # | Download | only in acpiexec
aeexec.c revision 1.1.1.8
      1      1.1    jruoho /******************************************************************************
      2      1.1    jruoho  *
      3      1.1    jruoho  * Module Name: aeexec - Support routines for AcpiExec utility
      4      1.1    jruoho  *
      5      1.1    jruoho  *****************************************************************************/
      6      1.1    jruoho 
      7  1.1.1.2    jruoho /*
      8  1.1.1.7  christos  * Copyright (C) 2000 - 2016, Intel Corp.
      9      1.1    jruoho  * All rights reserved.
     10      1.1    jruoho  *
     11  1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13  1.1.1.2    jruoho  * are met:
     14  1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.2    jruoho  *    without modification.
     17  1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.2    jruoho  *    binary redistribution.
     22  1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25  1.1.1.2    jruoho  *
     26  1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.2    jruoho  * Software Foundation.
     29  1.1.1.2    jruoho  *
     30  1.1.1.2    jruoho  * NO WARRANTY
     31  1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.2    jruoho  */
     43      1.1    jruoho 
     44      1.1    jruoho #include "aecommon.h"
     45      1.1    jruoho 
     46      1.1    jruoho #define _COMPONENT          ACPI_TOOLS
     47      1.1    jruoho         ACPI_MODULE_NAME    ("aeexec")
     48      1.1    jruoho 
     49      1.1    jruoho /* Local prototypes */
     50      1.1    jruoho 
     51  1.1.1.2    jruoho static ACPI_STATUS
     52      1.1    jruoho AeSetupConfiguration (
     53      1.1    jruoho     void                    *RegionAddr);
     54      1.1    jruoho 
     55  1.1.1.2    jruoho static void
     56      1.1    jruoho AeTestBufferArgument (
     57      1.1    jruoho     void);
     58      1.1    jruoho 
     59  1.1.1.2    jruoho static void
     60      1.1    jruoho AeTestPackageArgument (
     61      1.1    jruoho     void);
     62      1.1    jruoho 
     63  1.1.1.2    jruoho static ACPI_STATUS
     64      1.1    jruoho AeGetDevices (
     65      1.1    jruoho     ACPI_HANDLE             ObjHandle,
     66      1.1    jruoho     UINT32                  NestingLevel,
     67      1.1    jruoho     void                    *Context,
     68      1.1    jruoho     void                    **ReturnValue);
     69      1.1    jruoho 
     70  1.1.1.2    jruoho static ACPI_STATUS
     71      1.1    jruoho ExecuteOSI (
     72      1.1    jruoho     char                    *OsiString,
     73  1.1.1.8  christos     UINT64                  ExpectedResult);
     74      1.1    jruoho 
     75  1.1.1.2    jruoho static void
     76  1.1.1.3  christos AeMutexInterfaces (
     77  1.1.1.3  christos     void);
     78  1.1.1.3  christos 
     79  1.1.1.3  christos static void
     80      1.1    jruoho AeHardwareInterfaces (
     81      1.1    jruoho     void);
     82      1.1    jruoho 
     83  1.1.1.2    jruoho static void
     84      1.1    jruoho AeGenericRegisters (
     85      1.1    jruoho     void);
     86      1.1    jruoho 
     87  1.1.1.7  christos static void
     88  1.1.1.7  christos AeTestSleepData (
     89  1.1.1.7  christos     void);
     90  1.1.1.7  christos 
     91  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE)
     92  1.1.1.3  christos static void
     93  1.1.1.3  christos AfInstallGpeBlock (
     94  1.1.1.3  christos     void);
     95  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
     96  1.1.1.3  christos 
     97  1.1.1.3  christos extern unsigned char Ssdt2Code[];
     98      1.1    jruoho extern unsigned char Ssdt3Code[];
     99  1.1.1.3  christos extern unsigned char Ssdt4Code[];
    100      1.1    jruoho 
    101      1.1    jruoho 
    102      1.1    jruoho /******************************************************************************
    103      1.1    jruoho  *
    104      1.1    jruoho  * FUNCTION:    AeSetupConfiguration
    105      1.1    jruoho  *
    106      1.1    jruoho  * PARAMETERS:  RegionAddr          - Address for an ACPI table to be loaded
    107      1.1    jruoho  *                                    dynamically. Test purposes only.
    108      1.1    jruoho  *
    109      1.1    jruoho  * RETURN:      Status
    110      1.1    jruoho  *
    111      1.1    jruoho  * DESCRIPTION: Call AML _CFG configuration control method
    112      1.1    jruoho  *
    113      1.1    jruoho  *****************************************************************************/
    114      1.1    jruoho 
    115  1.1.1.2    jruoho static ACPI_STATUS
    116      1.1    jruoho AeSetupConfiguration (
    117      1.1    jruoho     void                    *RegionAddr)
    118      1.1    jruoho {
    119      1.1    jruoho     ACPI_OBJECT_LIST        ArgList;
    120      1.1    jruoho     ACPI_OBJECT             Arg[3];
    121      1.1    jruoho 
    122      1.1    jruoho 
    123      1.1    jruoho     /*
    124      1.1    jruoho      * Invoke _CFG method if present
    125      1.1    jruoho      */
    126      1.1    jruoho     ArgList.Count = 1;
    127      1.1    jruoho     ArgList.Pointer = Arg;
    128      1.1    jruoho 
    129      1.1    jruoho     Arg[0].Type = ACPI_TYPE_INTEGER;
    130      1.1    jruoho     Arg[0].Integer.Value = ACPI_TO_INTEGER (RegionAddr);
    131      1.1    jruoho 
    132  1.1.1.2    jruoho     (void) AcpiEvaluateObject (NULL, "\\_CFG", &ArgList, NULL);
    133      1.1    jruoho     return (AE_OK);
    134      1.1    jruoho }
    135      1.1    jruoho 
    136      1.1    jruoho 
    137  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE)
    138      1.1    jruoho /******************************************************************************
    139      1.1    jruoho  *
    140      1.1    jruoho  * FUNCTION:    AfInstallGpeBlock
    141      1.1    jruoho  *
    142      1.1    jruoho  * PARAMETERS:  None
    143      1.1    jruoho  *
    144      1.1    jruoho  * RETURN:      None
    145      1.1    jruoho  *
    146      1.1    jruoho  * DESCRIPTION: Test GPE block device initialization. Requires test ASL with
    147      1.1    jruoho  *              A \GPE2 device.
    148      1.1    jruoho  *
    149      1.1    jruoho  *****************************************************************************/
    150      1.1    jruoho 
    151  1.1.1.2    jruoho static void
    152      1.1    jruoho AfInstallGpeBlock (
    153      1.1    jruoho     void)
    154      1.1    jruoho {
    155      1.1    jruoho     ACPI_STATUS                 Status;
    156      1.1    jruoho     ACPI_HANDLE                 Handle;
    157      1.1    jruoho     ACPI_GENERIC_ADDRESS        BlockAddress;
    158      1.1    jruoho     ACPI_HANDLE                 GpeDevice;
    159  1.1.1.4  christos     ACPI_OBJECT_TYPE            Type;
    160      1.1    jruoho 
    161      1.1    jruoho 
    162  1.1.1.4  christos     /* _GPE should always exist */
    163  1.1.1.4  christos 
    164      1.1    jruoho     Status = AcpiGetHandle (NULL, "\\_GPE", &Handle);
    165  1.1.1.7  christos     ACPI_CHECK_OK (AcpiGetHandle, Status);
    166      1.1    jruoho     if (ACPI_FAILURE (Status))
    167      1.1    jruoho     {
    168      1.1    jruoho         return;
    169      1.1    jruoho     }
    170      1.1    jruoho 
    171  1.1.1.6  christos     memset (&BlockAddress, 0, sizeof (ACPI_GENERIC_ADDRESS));
    172      1.1    jruoho     BlockAddress.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY;
    173      1.1    jruoho     BlockAddress.Address = 0x76540000;
    174      1.1    jruoho 
    175  1.1.1.4  christos     /* Attempt to install a GPE block on GPE2 (if present) */
    176  1.1.1.4  christos 
    177  1.1.1.4  christos     Status = AcpiGetHandle (NULL, "\\GPE2", &Handle);
    178      1.1    jruoho     if (ACPI_SUCCESS (Status))
    179      1.1    jruoho     {
    180  1.1.1.4  christos         Status = AcpiGetType (Handle, &Type);
    181  1.1.1.4  christos         if (ACPI_FAILURE (Status) ||
    182  1.1.1.4  christos            (Type != ACPI_TYPE_DEVICE))
    183  1.1.1.4  christos         {
    184  1.1.1.4  christos             return;
    185  1.1.1.4  christos         }
    186  1.1.1.4  christos 
    187  1.1.1.4  christos         Status = AcpiInstallGpeBlock (Handle, &BlockAddress, 7, 8);
    188  1.1.1.7  christos         ACPI_CHECK_OK (AcpiInstallGpeBlock, Status);
    189  1.1.1.2    jruoho 
    190  1.1.1.4  christos         Status = AcpiInstallGpeHandler (Handle, 8,
    191  1.1.1.2    jruoho             ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    192  1.1.1.7  christos         ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    193      1.1    jruoho 
    194  1.1.1.4  christos         Status = AcpiEnableGpe (Handle, 8);
    195  1.1.1.7  christos         ACPI_CHECK_OK (AcpiEnableGpe, Status);
    196      1.1    jruoho 
    197      1.1    jruoho         Status = AcpiGetGpeDevice (0x30, &GpeDevice);
    198  1.1.1.7  christos         ACPI_CHECK_OK (AcpiGetGpeDevice, Status);
    199  1.1.1.2    jruoho 
    200      1.1    jruoho         Status = AcpiGetGpeDevice (0x42, &GpeDevice);
    201  1.1.1.7  christos         ACPI_CHECK_OK (AcpiGetGpeDevice, Status);
    202  1.1.1.2    jruoho 
    203      1.1    jruoho         Status = AcpiGetGpeDevice (AcpiCurrentGpeCount-1, &GpeDevice);
    204  1.1.1.7  christos         ACPI_CHECK_OK (AcpiGetGpeDevice, Status);
    205  1.1.1.2    jruoho 
    206      1.1    jruoho         Status = AcpiGetGpeDevice (AcpiCurrentGpeCount, &GpeDevice);
    207  1.1.1.7  christos         ACPI_CHECK_STATUS (AcpiGetGpeDevice, Status, AE_NOT_EXIST);
    208      1.1    jruoho 
    209  1.1.1.4  christos         Status = AcpiRemoveGpeHandler (Handle, 8, AeGpeHandler);
    210  1.1.1.7  christos         ACPI_CHECK_OK (AcpiRemoveGpeHandler, Status);
    211      1.1    jruoho     }
    212      1.1    jruoho 
    213  1.1.1.4  christos     /* Attempt to install a GPE block on GPE3 (if present) */
    214  1.1.1.4  christos 
    215  1.1.1.4  christos     Status = AcpiGetHandle (NULL, "\\GPE3", &Handle);
    216      1.1    jruoho     if (ACPI_SUCCESS (Status))
    217      1.1    jruoho     {
    218  1.1.1.4  christos         Status = AcpiGetType (Handle, &Type);
    219  1.1.1.4  christos         if (ACPI_FAILURE (Status) ||
    220  1.1.1.4  christos            (Type != ACPI_TYPE_DEVICE))
    221  1.1.1.4  christos         {
    222  1.1.1.4  christos             return;
    223  1.1.1.4  christos         }
    224  1.1.1.4  christos 
    225  1.1.1.4  christos         Status = AcpiInstallGpeBlock (Handle, &BlockAddress, 8, 11);
    226  1.1.1.7  christos         ACPI_CHECK_OK (AcpiInstallGpeBlock, Status);
    227      1.1    jruoho     }
    228      1.1    jruoho }
    229  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    230      1.1    jruoho 
    231      1.1    jruoho 
    232      1.1    jruoho /* Test using a Buffer object as a method argument */
    233      1.1    jruoho 
    234  1.1.1.2    jruoho static void
    235      1.1    jruoho AeTestBufferArgument (
    236      1.1    jruoho     void)
    237      1.1    jruoho {
    238      1.1    jruoho     ACPI_OBJECT_LIST        Params;
    239      1.1    jruoho     ACPI_OBJECT             BufArg;
    240  1.1.1.7  christos     UINT8                   Buffer[] =
    241  1.1.1.7  christos     {
    242      1.1    jruoho         0,0,0,0,
    243      1.1    jruoho         4,0,0,0,
    244  1.1.1.7  christos         1,2,3,4
    245  1.1.1.7  christos     };
    246      1.1    jruoho 
    247      1.1    jruoho 
    248      1.1    jruoho     BufArg.Type = ACPI_TYPE_BUFFER;
    249      1.1    jruoho     BufArg.Buffer.Length = 12;
    250      1.1    jruoho     BufArg.Buffer.Pointer = Buffer;
    251      1.1    jruoho 
    252      1.1    jruoho     Params.Count = 1;
    253      1.1    jruoho     Params.Pointer = &BufArg;
    254      1.1    jruoho 
    255  1.1.1.2    jruoho     (void) AcpiEvaluateObject (NULL, "\\BUF", &Params, NULL);
    256      1.1    jruoho }
    257      1.1    jruoho 
    258      1.1    jruoho 
    259  1.1.1.2    jruoho static ACPI_OBJECT                 PkgArg;
    260  1.1.1.2    jruoho static ACPI_OBJECT                 PkgElements[5];
    261  1.1.1.2    jruoho static ACPI_OBJECT                 Pkg2Elements[5];
    262  1.1.1.2    jruoho static ACPI_OBJECT_LIST            Params;
    263      1.1    jruoho 
    264      1.1    jruoho 
    265      1.1    jruoho /*
    266      1.1    jruoho  * Test using a Package object as an method argument
    267      1.1    jruoho  */
    268  1.1.1.2    jruoho static void
    269      1.1    jruoho AeTestPackageArgument (
    270      1.1    jruoho     void)
    271      1.1    jruoho {
    272      1.1    jruoho 
    273      1.1    jruoho     /* Main package */
    274      1.1    jruoho 
    275      1.1    jruoho     PkgArg.Type = ACPI_TYPE_PACKAGE;
    276      1.1    jruoho     PkgArg.Package.Count = 4;
    277      1.1    jruoho     PkgArg.Package.Elements = PkgElements;
    278      1.1    jruoho 
    279      1.1    jruoho     /* Main package elements */
    280      1.1    jruoho 
    281      1.1    jruoho     PkgElements[0].Type = ACPI_TYPE_INTEGER;
    282      1.1    jruoho     PkgElements[0].Integer.Value = 0x22228888;
    283      1.1    jruoho 
    284      1.1    jruoho     PkgElements[1].Type = ACPI_TYPE_STRING;
    285      1.1    jruoho     PkgElements[1].String.Length = sizeof ("Top-level package");
    286      1.1    jruoho     PkgElements[1].String.Pointer = "Top-level package";
    287      1.1    jruoho 
    288      1.1    jruoho     PkgElements[2].Type = ACPI_TYPE_BUFFER;
    289      1.1    jruoho     PkgElements[2].Buffer.Length = sizeof ("XXXX");
    290      1.1    jruoho     PkgElements[2].Buffer.Pointer = (UINT8 *) "XXXX";
    291      1.1    jruoho 
    292      1.1    jruoho     PkgElements[3].Type = ACPI_TYPE_PACKAGE;
    293      1.1    jruoho     PkgElements[3].Package.Count = 2;
    294      1.1    jruoho     PkgElements[3].Package.Elements = Pkg2Elements;
    295      1.1    jruoho 
    296  1.1.1.4  christos     /* Subpackage elements */
    297      1.1    jruoho 
    298      1.1    jruoho     Pkg2Elements[0].Type = ACPI_TYPE_INTEGER;
    299      1.1    jruoho     Pkg2Elements[0].Integer.Value = 0xAAAABBBB;
    300      1.1    jruoho 
    301      1.1    jruoho     Pkg2Elements[1].Type = ACPI_TYPE_STRING;
    302      1.1    jruoho     Pkg2Elements[1].String.Length = sizeof ("Nested Package");
    303      1.1    jruoho     Pkg2Elements[1].String.Pointer = "Nested Package";
    304      1.1    jruoho 
    305      1.1    jruoho     /* Parameter object */
    306      1.1    jruoho 
    307      1.1    jruoho     Params.Count = 1;
    308      1.1    jruoho     Params.Pointer = &PkgArg;
    309      1.1    jruoho 
    310  1.1.1.2    jruoho     (void) AcpiEvaluateObject (NULL, "\\_PKG", &Params, NULL);
    311      1.1    jruoho }
    312      1.1    jruoho 
    313      1.1    jruoho 
    314  1.1.1.2    jruoho static ACPI_STATUS
    315      1.1    jruoho AeGetDevices (
    316      1.1    jruoho     ACPI_HANDLE                     ObjHandle,
    317      1.1    jruoho     UINT32                          NestingLevel,
    318      1.1    jruoho     void                            *Context,
    319      1.1    jruoho     void                            **ReturnValue)
    320      1.1    jruoho {
    321      1.1    jruoho 
    322      1.1    jruoho     return (AE_OK);
    323      1.1    jruoho }
    324      1.1    jruoho 
    325      1.1    jruoho 
    326      1.1    jruoho /******************************************************************************
    327      1.1    jruoho  *
    328      1.1    jruoho  * FUNCTION:    ExecuteOSI
    329      1.1    jruoho  *
    330      1.1    jruoho  * PARAMETERS:  OsiString           - String passed to _OSI method
    331  1.1.1.8  christos  *              ExpectedResult      - 0 (FALSE) or ACPI_UINT64_MAX (TRUE)
    332      1.1    jruoho  *
    333      1.1    jruoho  * RETURN:      Status
    334      1.1    jruoho  *
    335      1.1    jruoho  * DESCRIPTION: Execute the internally implemented (in ACPICA) _OSI method.
    336      1.1    jruoho  *
    337      1.1    jruoho  *****************************************************************************/
    338      1.1    jruoho 
    339  1.1.1.2    jruoho static ACPI_STATUS
    340      1.1    jruoho ExecuteOSI (
    341      1.1    jruoho     char                    *OsiString,
    342  1.1.1.8  christos     UINT64                  ExpectedResult)
    343      1.1    jruoho {
    344      1.1    jruoho     ACPI_STATUS             Status;
    345      1.1    jruoho     ACPI_OBJECT_LIST        ArgList;
    346      1.1    jruoho     ACPI_OBJECT             Arg[1];
    347      1.1    jruoho     ACPI_BUFFER             ReturnValue;
    348      1.1    jruoho     ACPI_OBJECT             *Obj;
    349      1.1    jruoho 
    350      1.1    jruoho 
    351      1.1    jruoho     /* Setup input argument */
    352      1.1    jruoho 
    353      1.1    jruoho     ArgList.Count = 1;
    354      1.1    jruoho     ArgList.Pointer = Arg;
    355      1.1    jruoho 
    356      1.1    jruoho     Arg[0].Type = ACPI_TYPE_STRING;
    357      1.1    jruoho     Arg[0].String.Pointer = OsiString;
    358      1.1    jruoho     Arg[0].String.Length = strlen (Arg[0].String.Pointer);
    359      1.1    jruoho 
    360      1.1    jruoho     /* Ask ACPICA to allocate space for the return object */
    361      1.1    jruoho 
    362      1.1    jruoho     ReturnValue.Length = ACPI_ALLOCATE_BUFFER;
    363      1.1    jruoho 
    364      1.1    jruoho     Status = AcpiEvaluateObject (NULL, "\\_OSI", &ArgList, &ReturnValue);
    365      1.1    jruoho 
    366      1.1    jruoho     if (ACPI_FAILURE (Status))
    367      1.1    jruoho     {
    368  1.1.1.7  christos         AcpiOsPrintf (
    369  1.1.1.7  christos             "Could not execute _OSI method, %s\n",
    370      1.1    jruoho             AcpiFormatException (Status));
    371      1.1    jruoho         return (Status);
    372      1.1    jruoho     }
    373      1.1    jruoho 
    374  1.1.1.3  christos     Status = AE_ERROR;
    375  1.1.1.3  christos 
    376      1.1    jruoho     if (ReturnValue.Length < sizeof (ACPI_OBJECT))
    377      1.1    jruoho     {
    378  1.1.1.7  christos         AcpiOsPrintf (
    379  1.1.1.7  christos             "Return value from _OSI method too small, %.8X\n",
    380      1.1    jruoho             ReturnValue.Length);
    381  1.1.1.3  christos         goto ErrorExit;
    382      1.1    jruoho     }
    383      1.1    jruoho 
    384      1.1    jruoho     Obj = ReturnValue.Pointer;
    385      1.1    jruoho     if (Obj->Type != ACPI_TYPE_INTEGER)
    386      1.1    jruoho     {
    387  1.1.1.7  christos         AcpiOsPrintf (
    388  1.1.1.7  christos             "Invalid return type from _OSI method, %.2X\n", Obj->Type);
    389  1.1.1.3  christos         goto ErrorExit;
    390      1.1    jruoho     }
    391      1.1    jruoho 
    392      1.1    jruoho     if (Obj->Integer.Value != ExpectedResult)
    393      1.1    jruoho     {
    394  1.1.1.7  christos         AcpiOsPrintf (
    395  1.1.1.8  christos             "Invalid return value from _OSI, expected %8.8X%8.8X found %8.8X%8.8X\n",
    396  1.1.1.8  christos             ACPI_FORMAT_UINT64 (ExpectedResult),
    397  1.1.1.8  christos             ACPI_FORMAT_UINT64 (Obj->Integer.Value));
    398  1.1.1.3  christos         goto ErrorExit;
    399      1.1    jruoho     }
    400      1.1    jruoho 
    401  1.1.1.3  christos     Status = AE_OK;
    402  1.1.1.3  christos 
    403      1.1    jruoho     /* Reset the OSI data */
    404      1.1    jruoho 
    405      1.1    jruoho     AcpiGbl_OsiData = 0;
    406  1.1.1.3  christos 
    407  1.1.1.3  christos ErrorExit:
    408  1.1.1.3  christos 
    409  1.1.1.3  christos     /* Free a buffer created via ACPI_ALLOCATE_BUFFER */
    410  1.1.1.3  christos 
    411  1.1.1.3  christos     AcpiOsFree (ReturnValue.Pointer);
    412  1.1.1.3  christos     return (Status);
    413      1.1    jruoho }
    414      1.1    jruoho 
    415      1.1    jruoho 
    416      1.1    jruoho /******************************************************************************
    417      1.1    jruoho  *
    418      1.1    jruoho  * FUNCTION:    AeGenericRegisters
    419      1.1    jruoho  *
    420      1.1    jruoho  * DESCRIPTION: Call the AcpiRead/Write interfaces.
    421      1.1    jruoho  *
    422      1.1    jruoho  *****************************************************************************/
    423      1.1    jruoho 
    424  1.1.1.2    jruoho static ACPI_GENERIC_ADDRESS       GenericRegister;
    425      1.1    jruoho 
    426  1.1.1.2    jruoho static void
    427      1.1    jruoho AeGenericRegisters (
    428      1.1    jruoho     void)
    429      1.1    jruoho {
    430      1.1    jruoho     ACPI_STATUS             Status;
    431      1.1    jruoho     UINT64                  Value;
    432      1.1    jruoho 
    433      1.1    jruoho 
    434      1.1    jruoho     GenericRegister.Address = 0x1234;
    435      1.1    jruoho     GenericRegister.BitWidth = 64;
    436      1.1    jruoho     GenericRegister.BitOffset = 0;
    437      1.1    jruoho     GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
    438      1.1    jruoho 
    439      1.1    jruoho     Status = AcpiRead (&Value, &GenericRegister);
    440  1.1.1.7  christos     ACPI_CHECK_OK (AcpiRead, Status);
    441  1.1.1.2    jruoho 
    442      1.1    jruoho     Status = AcpiWrite (Value, &GenericRegister);
    443  1.1.1.7  christos     ACPI_CHECK_OK (AcpiWrite, Status);
    444      1.1    jruoho 
    445      1.1    jruoho     GenericRegister.Address = 0x12345678;
    446      1.1    jruoho     GenericRegister.BitOffset = 0;
    447      1.1    jruoho     GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY;
    448      1.1    jruoho 
    449      1.1    jruoho     Status = AcpiRead (&Value, &GenericRegister);
    450  1.1.1.7  christos     ACPI_CHECK_OK (AcpiRead, Status);
    451  1.1.1.2    jruoho 
    452      1.1    jruoho     Status = AcpiWrite (Value, &GenericRegister);
    453  1.1.1.7  christos     ACPI_CHECK_OK (AcpiWrite, Status);
    454      1.1    jruoho }
    455      1.1    jruoho 
    456      1.1    jruoho 
    457      1.1    jruoho /******************************************************************************
    458      1.1    jruoho  *
    459  1.1.1.3  christos  * FUNCTION:    AeMutexInterfaces
    460  1.1.1.3  christos  *
    461  1.1.1.3  christos  * DESCRIPTION: Exercise the AML mutex access interfaces
    462  1.1.1.3  christos  *
    463  1.1.1.3  christos  *****************************************************************************/
    464  1.1.1.3  christos 
    465  1.1.1.3  christos static void
    466  1.1.1.3  christos AeMutexInterfaces (
    467  1.1.1.3  christos     void)
    468  1.1.1.3  christos {
    469  1.1.1.3  christos     ACPI_STATUS             Status;
    470  1.1.1.3  christos     ACPI_HANDLE             MutexHandle;
    471  1.1.1.3  christos 
    472  1.1.1.3  christos 
    473  1.1.1.3  christos     /* Get a handle to an AML mutex */
    474  1.1.1.3  christos 
    475  1.1.1.3  christos     Status = AcpiGetHandle (NULL, "\\MTX1", &MutexHandle);
    476  1.1.1.3  christos     if (Status == AE_NOT_FOUND)
    477  1.1.1.3  christos     {
    478  1.1.1.3  christos         return;
    479  1.1.1.3  christos     }
    480  1.1.1.3  christos 
    481  1.1.1.7  christos     ACPI_CHECK_OK (AcpiGetHandle, Status);
    482  1.1.1.3  christos     if (ACPI_FAILURE (Status))
    483  1.1.1.3  christos     {
    484  1.1.1.3  christos         return;
    485  1.1.1.3  christos     }
    486  1.1.1.3  christos 
    487  1.1.1.3  christos     /* Acquire the  mutex */
    488  1.1.1.3  christos 
    489  1.1.1.3  christos     Status = AcpiAcquireMutex (NULL, "\\MTX1", 0xFFFF);
    490  1.1.1.7  christos     ACPI_CHECK_OK (AcpiAcquireMutex, Status);
    491  1.1.1.3  christos     if (ACPI_FAILURE (Status))
    492  1.1.1.3  christos     {
    493  1.1.1.3  christos         return;
    494  1.1.1.3  christos     }
    495  1.1.1.3  christos 
    496  1.1.1.3  christos     /* Release mutex with different parameters */
    497  1.1.1.3  christos 
    498  1.1.1.3  christos     Status = AcpiReleaseMutex (MutexHandle, NULL);
    499  1.1.1.7  christos     ACPI_CHECK_OK (AcpiReleaseMutex, Status);
    500  1.1.1.3  christos }
    501  1.1.1.3  christos 
    502  1.1.1.3  christos 
    503  1.1.1.3  christos /******************************************************************************
    504  1.1.1.3  christos  *
    505      1.1    jruoho  * FUNCTION:    AeHardwareInterfaces
    506      1.1    jruoho  *
    507      1.1    jruoho  * DESCRIPTION: Call various hardware support interfaces
    508      1.1    jruoho  *
    509      1.1    jruoho  *****************************************************************************/
    510      1.1    jruoho 
    511  1.1.1.2    jruoho static void
    512      1.1    jruoho AeHardwareInterfaces (
    513      1.1    jruoho     void)
    514      1.1    jruoho {
    515  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE)
    516  1.1.1.3  christos 
    517      1.1    jruoho     ACPI_STATUS             Status;
    518      1.1    jruoho     UINT32                  Value;
    519      1.1    jruoho 
    520      1.1    jruoho 
    521  1.1.1.3  christos     /* If Hardware Reduced flag is set, we are all done */
    522  1.1.1.3  christos 
    523  1.1.1.3  christos     if (AcpiGbl_ReducedHardware)
    524  1.1.1.3  christos     {
    525  1.1.1.3  christos         return;
    526  1.1.1.3  christos     }
    527  1.1.1.3  christos 
    528      1.1    jruoho     Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, 1);
    529  1.1.1.7  christos     ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
    530  1.1.1.2    jruoho 
    531      1.1    jruoho     Status = AcpiWriteBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, 1);
    532  1.1.1.7  christos     ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
    533  1.1.1.2    jruoho 
    534      1.1    jruoho     Status = AcpiWriteBitRegister (ACPI_BITREG_SLEEP_ENABLE, 1);
    535  1.1.1.7  christos     ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
    536  1.1.1.2    jruoho 
    537      1.1    jruoho     Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1);
    538  1.1.1.7  christos     ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
    539  1.1.1.2    jruoho 
    540      1.1    jruoho 
    541      1.1    jruoho     Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &Value);
    542  1.1.1.7  christos     ACPI_CHECK_OK (AcpiReadBitRegister, Status);
    543  1.1.1.2    jruoho 
    544      1.1    jruoho     Status = AcpiReadBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, &Value);
    545  1.1.1.7  christos     ACPI_CHECK_OK (AcpiReadBitRegister, Status);
    546  1.1.1.2    jruoho 
    547      1.1    jruoho     Status = AcpiReadBitRegister (ACPI_BITREG_SLEEP_ENABLE, &Value);
    548  1.1.1.7  christos     ACPI_CHECK_OK (AcpiReadBitRegister, Status);
    549  1.1.1.2    jruoho 
    550      1.1    jruoho     Status = AcpiReadBitRegister (ACPI_BITREG_ARB_DISABLE, &Value);
    551  1.1.1.7  christos     ACPI_CHECK_OK (AcpiReadBitRegister, Status);
    552  1.1.1.3  christos 
    553  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    554      1.1    jruoho }
    555      1.1    jruoho 
    556      1.1    jruoho 
    557      1.1    jruoho /******************************************************************************
    558      1.1    jruoho  *
    559  1.1.1.7  christos  * FUNCTION:    AeTestSleepData
    560  1.1.1.7  christos  *
    561  1.1.1.7  christos  * DESCRIPTION: Exercise the sleep/wake support (_S0, _S1, etc.)
    562  1.1.1.7  christos  *
    563  1.1.1.7  christos  *****************************************************************************/
    564  1.1.1.7  christos 
    565  1.1.1.7  christos static void
    566  1.1.1.7  christos AeTestSleepData (
    567  1.1.1.7  christos     void)
    568  1.1.1.7  christos {
    569  1.1.1.7  christos     int                     State;
    570  1.1.1.7  christos     UINT8                   TypeA;
    571  1.1.1.7  christos     UINT8                   TypeB;
    572  1.1.1.7  christos     ACPI_STATUS             Status;
    573  1.1.1.7  christos 
    574  1.1.1.7  christos 
    575  1.1.1.7  christos     /* Attempt to get sleep data for all known sleep states */
    576  1.1.1.7  christos 
    577  1.1.1.7  christos     for (State = ACPI_STATE_S0; State <= ACPI_S_STATES_MAX; State++)
    578  1.1.1.7  christos     {
    579  1.1.1.7  christos         Status = AcpiGetSleepTypeData ((UINT8) State, &TypeA, &TypeB);
    580  1.1.1.7  christos 
    581  1.1.1.7  christos         /* All sleep methods are optional */
    582  1.1.1.7  christos 
    583  1.1.1.7  christos         if (Status != AE_NOT_FOUND)
    584  1.1.1.7  christos         {
    585  1.1.1.7  christos             ACPI_CHECK_OK (AcpiGetSleepTypeData, Status);
    586  1.1.1.7  christos         }
    587  1.1.1.7  christos     }
    588  1.1.1.7  christos }
    589  1.1.1.7  christos 
    590  1.1.1.7  christos 
    591  1.1.1.7  christos /******************************************************************************
    592  1.1.1.7  christos  *
    593      1.1    jruoho  * FUNCTION:    AeMiscellaneousTests
    594      1.1    jruoho  *
    595      1.1    jruoho  * DESCRIPTION: Various ACPICA validation tests.
    596      1.1    jruoho  *
    597      1.1    jruoho  *****************************************************************************/
    598      1.1    jruoho 
    599      1.1    jruoho void
    600      1.1    jruoho AeMiscellaneousTests (
    601      1.1    jruoho     void)
    602      1.1    jruoho {
    603      1.1    jruoho     ACPI_BUFFER             ReturnBuf;
    604      1.1    jruoho     char                    Buffer[32];
    605      1.1    jruoho     ACPI_STATUS             Status;
    606  1.1.1.3  christos     ACPI_STATISTICS         Stats;
    607  1.1.1.3  christos     ACPI_HANDLE             Handle;
    608  1.1.1.3  christos 
    609  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE)
    610      1.1    jruoho     UINT32                  LockHandle1;
    611      1.1    jruoho     UINT32                  LockHandle2;
    612  1.1.1.7  christos     ACPI_VENDOR_UUID        Uuid =
    613  1.1.1.7  christos         {0, {ACPI_INIT_UUID (0,0,0,0,0,0,0,0,0,0,0)}};
    614  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    615  1.1.1.3  christos 
    616  1.1.1.3  christos 
    617  1.1.1.3  christos     Status = AcpiGetHandle (NULL, "\\", &Handle);
    618  1.1.1.7  christos     ACPI_CHECK_OK (AcpiGetHandle, Status);
    619  1.1.1.3  christos 
    620  1.1.1.3  christos     if (AcpiGbl_DoInterfaceTests)
    621  1.1.1.3  christos     {
    622  1.1.1.3  christos         /*
    623  1.1.1.3  christos          * Tests for AcpiLoadTable and AcpiUnloadParentTable
    624  1.1.1.3  christos          */
    625  1.1.1.3  christos 
    626  1.1.1.3  christos         /* Attempt unload of DSDT, should fail */
    627  1.1.1.3  christos 
    628  1.1.1.3  christos         Status = AcpiGetHandle (NULL, "\\_SB_", &Handle);
    629  1.1.1.7  christos         ACPI_CHECK_OK (AcpiGetHandle, Status);
    630  1.1.1.3  christos 
    631  1.1.1.3  christos         Status = AcpiUnloadParentTable (Handle);
    632  1.1.1.7  christos         ACPI_CHECK_STATUS (AcpiUnloadParentTable, Status, AE_TYPE);
    633      1.1    jruoho 
    634  1.1.1.3  christos         /* Load and unload SSDT4 */
    635  1.1.1.3  christos 
    636  1.1.1.3  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code);
    637  1.1.1.7  christos         ACPI_CHECK_OK (AcpiLoadTable, Status);
    638  1.1.1.3  christos 
    639  1.1.1.3  christos         Status = AcpiGetHandle (NULL, "\\_T96", &Handle);
    640  1.1.1.7  christos         ACPI_CHECK_OK (AcpiGetHandle, Status);
    641  1.1.1.3  christos 
    642  1.1.1.3  christos         Status = AcpiUnloadParentTable (Handle);
    643  1.1.1.7  christos         ACPI_CHECK_OK (AcpiUnloadParentTable, Status);
    644  1.1.1.3  christos 
    645  1.1.1.3  christos         /* Re-load SSDT4 */
    646  1.1.1.3  christos 
    647  1.1.1.3  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code);
    648  1.1.1.7  christos         ACPI_CHECK_OK (AcpiLoadTable, Status);
    649  1.1.1.3  christos 
    650  1.1.1.3  christos         /* Unload and re-load SSDT2 (SSDT2 is in the XSDT) */
    651  1.1.1.3  christos 
    652  1.1.1.3  christos         Status = AcpiGetHandle (NULL, "\\_T99", &Handle);
    653  1.1.1.7  christos         ACPI_CHECK_OK (AcpiGetHandle, Status);
    654  1.1.1.3  christos 
    655  1.1.1.3  christos         Status = AcpiUnloadParentTable (Handle);
    656  1.1.1.7  christos         ACPI_CHECK_OK (AcpiUnloadParentTable, Status);
    657  1.1.1.3  christos 
    658  1.1.1.3  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt2Code);
    659  1.1.1.7  christos         ACPI_CHECK_OK (AcpiLoadTable, Status);
    660  1.1.1.3  christos 
    661  1.1.1.3  christos         /* Load OEM9 table (causes table override) */
    662  1.1.1.3  christos 
    663  1.1.1.3  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt3Code);
    664  1.1.1.7  christos         ACPI_CHECK_OK (AcpiLoadTable, Status);
    665  1.1.1.3  christos     }
    666      1.1    jruoho 
    667      1.1    jruoho     AeHardwareInterfaces ();
    668      1.1    jruoho     AeGenericRegisters ();
    669      1.1    jruoho     AeSetupConfiguration (Ssdt3Code);
    670      1.1    jruoho 
    671      1.1    jruoho     AeTestBufferArgument();
    672      1.1    jruoho     AeTestPackageArgument ();
    673  1.1.1.3  christos     AeMutexInterfaces ();
    674  1.1.1.7  christos     AeTestSleepData ();
    675  1.1.1.2    jruoho 
    676  1.1.1.3  christos     /* Test _OSI install/remove */
    677  1.1.1.2    jruoho 
    678  1.1.1.2    jruoho     Status = AcpiInstallInterface ("");
    679  1.1.1.7  christos     ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_BAD_PARAMETER);
    680  1.1.1.2    jruoho 
    681  1.1.1.2    jruoho     Status = AcpiInstallInterface ("TestString");
    682  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallInterface, Status);
    683  1.1.1.2    jruoho 
    684  1.1.1.2    jruoho     Status = AcpiInstallInterface ("TestString");
    685  1.1.1.7  christos     ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_ALREADY_EXISTS);
    686  1.1.1.2    jruoho 
    687  1.1.1.2    jruoho     Status = AcpiRemoveInterface ("Windows 2006");
    688  1.1.1.7  christos     ACPI_CHECK_OK (AcpiRemoveInterface, Status);
    689  1.1.1.2    jruoho 
    690  1.1.1.2    jruoho     Status = AcpiRemoveInterface ("TestString");
    691  1.1.1.7  christos     ACPI_CHECK_OK (AcpiRemoveInterface, Status);
    692  1.1.1.2    jruoho 
    693  1.1.1.2    jruoho     Status = AcpiRemoveInterface ("XXXXXX");
    694  1.1.1.7  christos     ACPI_CHECK_STATUS (AcpiRemoveInterface, Status, AE_NOT_EXIST);
    695  1.1.1.2    jruoho 
    696  1.1.1.2    jruoho     Status = AcpiInstallInterface ("AnotherTestString");
    697  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallInterface, Status);
    698  1.1.1.2    jruoho 
    699  1.1.1.3  christos     /* Test _OSI execution */
    700  1.1.1.3  christos 
    701  1.1.1.8  christos     Status = ExecuteOSI ("Extended Address Space Descriptor", ACPI_UINT64_MAX);
    702  1.1.1.7  christos     ACPI_CHECK_OK (ExecuteOSI, Status);
    703  1.1.1.2    jruoho 
    704  1.1.1.8  christos     Status = ExecuteOSI ("Windows 2001", ACPI_UINT64_MAX);
    705  1.1.1.7  christos     ACPI_CHECK_OK (ExecuteOSI, Status);
    706  1.1.1.2    jruoho 
    707  1.1.1.2    jruoho     Status = ExecuteOSI ("MichiganTerminalSystem", 0);
    708  1.1.1.7  christos     ACPI_CHECK_OK (ExecuteOSI, Status);
    709      1.1    jruoho 
    710      1.1    jruoho 
    711      1.1    jruoho     ReturnBuf.Length = 32;
    712      1.1    jruoho     ReturnBuf.Pointer = Buffer;
    713      1.1    jruoho 
    714  1.1.1.7  christos     Status = AcpiGetName (ACPI_ROOT_OBJECT,
    715  1.1.1.7  christos         ACPI_FULL_PATHNAME_NO_TRAILING, &ReturnBuf);
    716  1.1.1.7  christos     ACPI_CHECK_OK (AcpiGetName, Status);
    717  1.1.1.2    jruoho 
    718  1.1.1.3  christos     /* Get Devices */
    719  1.1.1.3  christos 
    720  1.1.1.3  christos     Status = AcpiGetDevices (NULL, AeGetDevices, NULL, NULL);
    721  1.1.1.7  christos     ACPI_CHECK_OK (AcpiGetDevices, Status);
    722  1.1.1.3  christos 
    723  1.1.1.3  christos     Status = AcpiGetStatistics (&Stats);
    724  1.1.1.7  christos     ACPI_CHECK_OK (AcpiGetStatistics, Status);
    725  1.1.1.3  christos 
    726  1.1.1.3  christos 
    727  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE)
    728  1.1.1.2    jruoho 
    729  1.1.1.2    jruoho     Status = AcpiInstallGlobalEventHandler (AeGlobalEventHandler, NULL);
    730  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGlobalEventHandler, Status);
    731      1.1    jruoho 
    732  1.1.1.3  christos     /* If Hardware Reduced flag is set, we are all done */
    733  1.1.1.3  christos 
    734  1.1.1.3  christos     if (AcpiGbl_ReducedHardware)
    735  1.1.1.3  christos     {
    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     Status = AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0);
    740  1.1.1.7  christos     ACPI_CHECK_OK (AcpiEnableEvent, Status);
    741  1.1.1.3  christos 
    742      1.1    jruoho     /*
    743      1.1    jruoho      * GPEs: Handlers, enable/disable, etc.
    744      1.1    jruoho      */
    745  1.1.1.7  christos     Status = AcpiInstallGpeHandler (NULL, 0,
    746  1.1.1.7  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    747  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    748  1.1.1.2    jruoho 
    749  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 0);
    750  1.1.1.7  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    751  1.1.1.2    jruoho 
    752  1.1.1.2    jruoho     Status = AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler);
    753  1.1.1.7  christos     ACPI_CHECK_OK (AcpiRemoveGpeHandler, Status);
    754  1.1.1.2    jruoho 
    755  1.1.1.7  christos     Status = AcpiInstallGpeHandler (NULL, 0,
    756  1.1.1.7  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    757  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    758  1.1.1.2    jruoho 
    759  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 0);
    760  1.1.1.7  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    761  1.1.1.2    jruoho 
    762  1.1.1.2    jruoho     Status = AcpiSetGpe (NULL, 0, ACPI_GPE_DISABLE);
    763  1.1.1.7  christos     ACPI_CHECK_OK (AcpiSetGpe, Status);
    764  1.1.1.2    jruoho 
    765  1.1.1.2    jruoho     Status = AcpiSetGpe (NULL, 0, ACPI_GPE_ENABLE);
    766  1.1.1.7  christos     ACPI_CHECK_OK (AcpiSetGpe, Status);
    767  1.1.1.2    jruoho 
    768  1.1.1.2    jruoho 
    769  1.1.1.7  christos     Status = AcpiInstallGpeHandler (NULL, 1,
    770  1.1.1.7  christos         ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
    771  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    772  1.1.1.2    jruoho 
    773  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 1);
    774  1.1.1.7  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    775  1.1.1.2    jruoho 
    776  1.1.1.2    jruoho 
    777  1.1.1.7  christos     Status = AcpiInstallGpeHandler (NULL, 2,
    778  1.1.1.7  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    779  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    780  1.1.1.2    jruoho 
    781  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 2);
    782  1.1.1.7  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    783  1.1.1.2    jruoho 
    784  1.1.1.2    jruoho 
    785  1.1.1.7  christos     Status = AcpiInstallGpeHandler (NULL, 3,
    786  1.1.1.7  christos         ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
    787  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    788  1.1.1.2    jruoho 
    789  1.1.1.7  christos     Status = AcpiInstallGpeHandler (NULL, 4,
    790  1.1.1.7  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    791  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    792  1.1.1.2    jruoho 
    793  1.1.1.7  christos     Status = AcpiInstallGpeHandler (NULL, 5,
    794  1.1.1.7  christos         ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
    795  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    796  1.1.1.2    jruoho 
    797  1.1.1.2    jruoho     Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
    798  1.1.1.7  christos     ACPI_CHECK_OK (AcpiGetHandle, Status);
    799  1.1.1.2    jruoho 
    800  1.1.1.2    jruoho     Status = AcpiSetupGpeForWake (Handle, NULL, 5);
    801  1.1.1.7  christos     ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
    802  1.1.1.2    jruoho 
    803  1.1.1.2    jruoho     Status = AcpiSetGpeWakeMask (NULL, 5, ACPI_GPE_ENABLE);
    804  1.1.1.7  christos     ACPI_CHECK_OK (AcpiSetGpeWakeMask, Status);
    805  1.1.1.2    jruoho 
    806  1.1.1.2    jruoho     Status = AcpiSetupGpeForWake (Handle, NULL, 6);
    807  1.1.1.7  christos     ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
    808  1.1.1.2    jruoho 
    809  1.1.1.3  christos     Status = AcpiSetupGpeForWake (ACPI_ROOT_OBJECT, NULL, 6);
    810  1.1.1.7  christos     ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
    811  1.1.1.3  christos 
    812  1.1.1.2    jruoho     Status = AcpiSetupGpeForWake (Handle, NULL, 9);
    813  1.1.1.7  christos     ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
    814  1.1.1.2    jruoho 
    815  1.1.1.7  christos     Status = AcpiInstallGpeHandler (NULL, 0x19,
    816  1.1.1.7  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    817  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    818  1.1.1.2    jruoho 
    819  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 0x19);
    820  1.1.1.7  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    821  1.1.1.2    jruoho 
    822  1.1.1.2    jruoho 
    823  1.1.1.4  christos     /* GPE block 1 */
    824  1.1.1.4  christos 
    825  1.1.1.7  christos     Status = AcpiInstallGpeHandler (NULL, 101,
    826  1.1.1.7  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    827  1.1.1.7  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    828  1.1.1.2    jruoho 
    829  1.1.1.4  christos     Status = AcpiEnableGpe (NULL, 101);
    830  1.1.1.7  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    831  1.1.1.2    jruoho 
    832  1.1.1.4  christos     Status = AcpiDisableGpe (NULL, 101);
    833  1.1.1.7  christos     ACPI_CHECK_OK (AcpiDisableGpe, Status);
    834      1.1    jruoho 
    835      1.1    jruoho     AfInstallGpeBlock ();
    836      1.1    jruoho 
    837  1.1.1.2    jruoho     /* Here is where the GPEs are actually "enabled" */
    838  1.1.1.2    jruoho 
    839  1.1.1.2    jruoho     Status = AcpiUpdateAllGpes ();
    840  1.1.1.7  christos     ACPI_CHECK_OK (AcpiUpdateAllGpes, Status);
    841      1.1    jruoho 
    842      1.1    jruoho     Status = AcpiGetHandle (NULL, "RSRC", &Handle);
    843      1.1    jruoho     if (ACPI_SUCCESS (Status))
    844      1.1    jruoho     {
    845      1.1    jruoho         ReturnBuf.Length = ACPI_ALLOCATE_BUFFER;
    846      1.1    jruoho 
    847      1.1    jruoho         Status = AcpiGetVendorResource (Handle, "_CRS", &Uuid, &ReturnBuf);
    848      1.1    jruoho         if (ACPI_SUCCESS (Status))
    849      1.1    jruoho         {
    850      1.1    jruoho             AcpiOsFree (ReturnBuf.Pointer);
    851      1.1    jruoho         }
    852      1.1    jruoho     }
    853      1.1    jruoho 
    854      1.1    jruoho     /* Test global lock */
    855      1.1    jruoho 
    856      1.1    jruoho     Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1);
    857  1.1.1.7  christos     ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status);
    858      1.1    jruoho 
    859      1.1    jruoho     Status = AcpiAcquireGlobalLock (0x5, &LockHandle2);
    860  1.1.1.7  christos     ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status);
    861      1.1    jruoho 
    862      1.1    jruoho     Status = AcpiReleaseGlobalLock (LockHandle1);
    863  1.1.1.7  christos     ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status);
    864      1.1    jruoho 
    865      1.1    jruoho     Status = AcpiReleaseGlobalLock (LockHandle2);
    866  1.1.1.7  christos     ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status);
    867      1.1    jruoho 
    868  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    869      1.1    jruoho }
    870