Home | History | Annotate | Line # | Download | only in acpiexec
aeexec.c revision 1.1.1.3
      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.3  christos  * Copyright (C) 2000 - 2013, 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    jruoho     UINT32                  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.3  christos #if (!ACPI_REDUCED_HARDWARE)
     88  1.1.1.3  christos static void
     89  1.1.1.3  christos AfInstallGpeBlock (
     90  1.1.1.3  christos     void);
     91  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
     92  1.1.1.3  christos 
     93  1.1.1.3  christos extern unsigned char Ssdt2Code[];
     94      1.1    jruoho extern unsigned char Ssdt3Code[];
     95  1.1.1.3  christos extern unsigned char Ssdt4Code[];
     96      1.1    jruoho 
     97      1.1    jruoho 
     98      1.1    jruoho /******************************************************************************
     99      1.1    jruoho  *
    100      1.1    jruoho  * FUNCTION:    AeSetupConfiguration
    101      1.1    jruoho  *
    102      1.1    jruoho  * PARAMETERS:  RegionAddr          - Address for an ACPI table to be loaded
    103      1.1    jruoho  *                                    dynamically. Test purposes only.
    104      1.1    jruoho  *
    105      1.1    jruoho  * RETURN:      Status
    106      1.1    jruoho  *
    107      1.1    jruoho  * DESCRIPTION: Call AML _CFG configuration control method
    108      1.1    jruoho  *
    109      1.1    jruoho  *****************************************************************************/
    110      1.1    jruoho 
    111  1.1.1.2    jruoho static ACPI_STATUS
    112      1.1    jruoho AeSetupConfiguration (
    113      1.1    jruoho     void                    *RegionAddr)
    114      1.1    jruoho {
    115      1.1    jruoho     ACPI_OBJECT_LIST        ArgList;
    116      1.1    jruoho     ACPI_OBJECT             Arg[3];
    117      1.1    jruoho 
    118      1.1    jruoho 
    119      1.1    jruoho     /*
    120      1.1    jruoho      * Invoke _CFG method if present
    121      1.1    jruoho      */
    122      1.1    jruoho     ArgList.Count = 1;
    123      1.1    jruoho     ArgList.Pointer = Arg;
    124      1.1    jruoho 
    125      1.1    jruoho     Arg[0].Type = ACPI_TYPE_INTEGER;
    126      1.1    jruoho     Arg[0].Integer.Value = ACPI_TO_INTEGER (RegionAddr);
    127      1.1    jruoho 
    128  1.1.1.2    jruoho     (void) AcpiEvaluateObject (NULL, "\\_CFG", &ArgList, NULL);
    129      1.1    jruoho     return (AE_OK);
    130      1.1    jruoho }
    131      1.1    jruoho 
    132      1.1    jruoho 
    133  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE)
    134      1.1    jruoho /******************************************************************************
    135      1.1    jruoho  *
    136      1.1    jruoho  * FUNCTION:    AfInstallGpeBlock
    137      1.1    jruoho  *
    138      1.1    jruoho  * PARAMETERS:  None
    139      1.1    jruoho  *
    140      1.1    jruoho  * RETURN:      None
    141      1.1    jruoho  *
    142      1.1    jruoho  * DESCRIPTION: Test GPE block device initialization. Requires test ASL with
    143      1.1    jruoho  *              A \GPE2 device.
    144      1.1    jruoho  *
    145      1.1    jruoho  *****************************************************************************/
    146      1.1    jruoho 
    147  1.1.1.2    jruoho static void
    148      1.1    jruoho AfInstallGpeBlock (
    149      1.1    jruoho     void)
    150      1.1    jruoho {
    151      1.1    jruoho     ACPI_STATUS                 Status;
    152      1.1    jruoho     ACPI_HANDLE                 Handle;
    153      1.1    jruoho     ACPI_HANDLE                 Handle2 = NULL;
    154      1.1    jruoho     ACPI_HANDLE                 Handle3 = NULL;
    155      1.1    jruoho     ACPI_GENERIC_ADDRESS        BlockAddress;
    156      1.1    jruoho     ACPI_HANDLE                 GpeDevice;
    157      1.1    jruoho 
    158      1.1    jruoho 
    159      1.1    jruoho     Status = AcpiGetHandle (NULL, "\\_GPE", &Handle);
    160      1.1    jruoho     if (ACPI_FAILURE (Status))
    161      1.1    jruoho     {
    162      1.1    jruoho         return;
    163      1.1    jruoho     }
    164      1.1    jruoho 
    165      1.1    jruoho     ACPI_MEMSET (&BlockAddress, 0, sizeof (ACPI_GENERIC_ADDRESS));
    166      1.1    jruoho     BlockAddress.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY;
    167      1.1    jruoho     BlockAddress.Address = 0x76540000;
    168      1.1    jruoho 
    169      1.1    jruoho     Status = AcpiGetHandle (NULL, "\\GPE2", &Handle2);
    170      1.1    jruoho     if (ACPI_SUCCESS (Status))
    171      1.1    jruoho     {
    172      1.1    jruoho         Status = AcpiInstallGpeBlock (Handle2, &BlockAddress, 7, 8);
    173  1.1.1.2    jruoho         AE_CHECK_OK (AcpiInstallGpeBlock, Status);
    174  1.1.1.2    jruoho 
    175  1.1.1.2    jruoho         Status = AcpiInstallGpeHandler (Handle2, 8,
    176  1.1.1.2    jruoho             ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    177  1.1.1.2    jruoho         AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    178      1.1    jruoho 
    179  1.1.1.2    jruoho         Status = AcpiEnableGpe (Handle2, 8);
    180  1.1.1.2    jruoho         AE_CHECK_OK (AcpiEnableGpe, Status);
    181      1.1    jruoho 
    182      1.1    jruoho         Status = AcpiGetGpeDevice (0x30, &GpeDevice);
    183  1.1.1.2    jruoho         AE_CHECK_OK (AcpiGetGpeDevice, Status);
    184  1.1.1.2    jruoho 
    185      1.1    jruoho         Status = AcpiGetGpeDevice (0x42, &GpeDevice);
    186  1.1.1.2    jruoho         AE_CHECK_OK (AcpiGetGpeDevice, Status);
    187  1.1.1.2    jruoho 
    188      1.1    jruoho         Status = AcpiGetGpeDevice (AcpiCurrentGpeCount-1, &GpeDevice);
    189  1.1.1.2    jruoho         AE_CHECK_OK (AcpiGetGpeDevice, Status);
    190  1.1.1.2    jruoho 
    191      1.1    jruoho         Status = AcpiGetGpeDevice (AcpiCurrentGpeCount, &GpeDevice);
    192  1.1.1.2    jruoho         AE_CHECK_STATUS (AcpiGetGpeDevice, Status, AE_NOT_EXIST);
    193      1.1    jruoho 
    194  1.1.1.2    jruoho         Status = AcpiRemoveGpeHandler (Handle2, 8, AeGpeHandler);
    195  1.1.1.2    jruoho         AE_CHECK_OK (AcpiRemoveGpeHandler, Status);
    196      1.1    jruoho     }
    197      1.1    jruoho 
    198      1.1    jruoho     Status = AcpiGetHandle (NULL, "\\GPE3", &Handle3);
    199      1.1    jruoho     if (ACPI_SUCCESS (Status))
    200      1.1    jruoho     {
    201      1.1    jruoho         Status = AcpiInstallGpeBlock (Handle3, &BlockAddress, 8, 11);
    202  1.1.1.2    jruoho         AE_CHECK_OK (AcpiInstallGpeBlock, Status);
    203      1.1    jruoho     }
    204      1.1    jruoho }
    205  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    206      1.1    jruoho 
    207      1.1    jruoho 
    208      1.1    jruoho /* Test using a Buffer object as a method argument */
    209      1.1    jruoho 
    210  1.1.1.2    jruoho static void
    211      1.1    jruoho AeTestBufferArgument (
    212      1.1    jruoho     void)
    213      1.1    jruoho {
    214      1.1    jruoho     ACPI_OBJECT_LIST        Params;
    215      1.1    jruoho     ACPI_OBJECT             BufArg;
    216      1.1    jruoho     UINT8                   Buffer[] = {
    217      1.1    jruoho         0,0,0,0,
    218      1.1    jruoho         4,0,0,0,
    219      1.1    jruoho         1,2,3,4};
    220      1.1    jruoho 
    221      1.1    jruoho 
    222      1.1    jruoho     BufArg.Type = ACPI_TYPE_BUFFER;
    223      1.1    jruoho     BufArg.Buffer.Length = 12;
    224      1.1    jruoho     BufArg.Buffer.Pointer = Buffer;
    225      1.1    jruoho 
    226      1.1    jruoho     Params.Count = 1;
    227      1.1    jruoho     Params.Pointer = &BufArg;
    228      1.1    jruoho 
    229  1.1.1.2    jruoho     (void) AcpiEvaluateObject (NULL, "\\BUF", &Params, NULL);
    230      1.1    jruoho }
    231      1.1    jruoho 
    232      1.1    jruoho 
    233  1.1.1.2    jruoho static ACPI_OBJECT                 PkgArg;
    234  1.1.1.2    jruoho static ACPI_OBJECT                 PkgElements[5];
    235  1.1.1.2    jruoho static ACPI_OBJECT                 Pkg2Elements[5];
    236  1.1.1.2    jruoho static ACPI_OBJECT_LIST            Params;
    237      1.1    jruoho 
    238      1.1    jruoho 
    239      1.1    jruoho /*
    240      1.1    jruoho  * Test using a Package object as an method argument
    241      1.1    jruoho  */
    242  1.1.1.2    jruoho static void
    243      1.1    jruoho AeTestPackageArgument (
    244      1.1    jruoho     void)
    245      1.1    jruoho {
    246      1.1    jruoho 
    247      1.1    jruoho     /* Main package */
    248      1.1    jruoho 
    249      1.1    jruoho     PkgArg.Type = ACPI_TYPE_PACKAGE;
    250      1.1    jruoho     PkgArg.Package.Count = 4;
    251      1.1    jruoho     PkgArg.Package.Elements = PkgElements;
    252      1.1    jruoho 
    253      1.1    jruoho     /* Main package elements */
    254      1.1    jruoho 
    255      1.1    jruoho     PkgElements[0].Type = ACPI_TYPE_INTEGER;
    256      1.1    jruoho     PkgElements[0].Integer.Value = 0x22228888;
    257      1.1    jruoho 
    258      1.1    jruoho     PkgElements[1].Type = ACPI_TYPE_STRING;
    259      1.1    jruoho     PkgElements[1].String.Length = sizeof ("Top-level package");
    260      1.1    jruoho     PkgElements[1].String.Pointer = "Top-level package";
    261      1.1    jruoho 
    262      1.1    jruoho     PkgElements[2].Type = ACPI_TYPE_BUFFER;
    263      1.1    jruoho     PkgElements[2].Buffer.Length = sizeof ("XXXX");
    264      1.1    jruoho     PkgElements[2].Buffer.Pointer = (UINT8 *) "XXXX";
    265      1.1    jruoho 
    266      1.1    jruoho     PkgElements[3].Type = ACPI_TYPE_PACKAGE;
    267      1.1    jruoho     PkgElements[3].Package.Count = 2;
    268      1.1    jruoho     PkgElements[3].Package.Elements = Pkg2Elements;
    269      1.1    jruoho 
    270      1.1    jruoho     /* Sub-package elements */
    271      1.1    jruoho 
    272      1.1    jruoho     Pkg2Elements[0].Type = ACPI_TYPE_INTEGER;
    273      1.1    jruoho     Pkg2Elements[0].Integer.Value = 0xAAAABBBB;
    274      1.1    jruoho 
    275      1.1    jruoho     Pkg2Elements[1].Type = ACPI_TYPE_STRING;
    276      1.1    jruoho     Pkg2Elements[1].String.Length = sizeof ("Nested Package");
    277      1.1    jruoho     Pkg2Elements[1].String.Pointer = "Nested Package";
    278      1.1    jruoho 
    279      1.1    jruoho     /* Parameter object */
    280      1.1    jruoho 
    281      1.1    jruoho     Params.Count = 1;
    282      1.1    jruoho     Params.Pointer = &PkgArg;
    283      1.1    jruoho 
    284  1.1.1.2    jruoho     (void) AcpiEvaluateObject (NULL, "\\_PKG", &Params, NULL);
    285      1.1    jruoho }
    286      1.1    jruoho 
    287      1.1    jruoho 
    288  1.1.1.2    jruoho static ACPI_STATUS
    289      1.1    jruoho AeGetDevices (
    290      1.1    jruoho     ACPI_HANDLE                     ObjHandle,
    291      1.1    jruoho     UINT32                          NestingLevel,
    292      1.1    jruoho     void                            *Context,
    293      1.1    jruoho     void                            **ReturnValue)
    294      1.1    jruoho {
    295      1.1    jruoho 
    296      1.1    jruoho     return (AE_OK);
    297      1.1    jruoho }
    298      1.1    jruoho 
    299      1.1    jruoho 
    300      1.1    jruoho /******************************************************************************
    301      1.1    jruoho  *
    302      1.1    jruoho  * FUNCTION:    ExecuteOSI
    303      1.1    jruoho  *
    304      1.1    jruoho  * PARAMETERS:  OsiString           - String passed to _OSI method
    305      1.1    jruoho  *              ExpectedResult      - 0 (FALSE) or 0xFFFFFFFF (TRUE)
    306      1.1    jruoho  *
    307      1.1    jruoho  * RETURN:      Status
    308      1.1    jruoho  *
    309      1.1    jruoho  * DESCRIPTION: Execute the internally implemented (in ACPICA) _OSI method.
    310      1.1    jruoho  *
    311      1.1    jruoho  *****************************************************************************/
    312      1.1    jruoho 
    313  1.1.1.2    jruoho static ACPI_STATUS
    314      1.1    jruoho ExecuteOSI (
    315      1.1    jruoho     char                    *OsiString,
    316      1.1    jruoho     UINT32                  ExpectedResult)
    317      1.1    jruoho {
    318      1.1    jruoho     ACPI_STATUS             Status;
    319      1.1    jruoho     ACPI_OBJECT_LIST        ArgList;
    320      1.1    jruoho     ACPI_OBJECT             Arg[1];
    321      1.1    jruoho     ACPI_BUFFER             ReturnValue;
    322      1.1    jruoho     ACPI_OBJECT             *Obj;
    323      1.1    jruoho 
    324      1.1    jruoho 
    325      1.1    jruoho     /* Setup input argument */
    326      1.1    jruoho 
    327      1.1    jruoho     ArgList.Count = 1;
    328      1.1    jruoho     ArgList.Pointer = Arg;
    329      1.1    jruoho 
    330      1.1    jruoho     Arg[0].Type = ACPI_TYPE_STRING;
    331      1.1    jruoho     Arg[0].String.Pointer = OsiString;
    332      1.1    jruoho     Arg[0].String.Length = strlen (Arg[0].String.Pointer);
    333      1.1    jruoho 
    334      1.1    jruoho     /* Ask ACPICA to allocate space for the return object */
    335      1.1    jruoho 
    336      1.1    jruoho     ReturnValue.Length = ACPI_ALLOCATE_BUFFER;
    337      1.1    jruoho 
    338      1.1    jruoho     Status = AcpiEvaluateObject (NULL, "\\_OSI", &ArgList, &ReturnValue);
    339      1.1    jruoho 
    340      1.1    jruoho     if (ACPI_FAILURE (Status))
    341      1.1    jruoho     {
    342      1.1    jruoho         AcpiOsPrintf ("Could not execute _OSI method, %s\n",
    343      1.1    jruoho             AcpiFormatException (Status));
    344      1.1    jruoho         return (Status);
    345      1.1    jruoho     }
    346      1.1    jruoho 
    347  1.1.1.3  christos     Status = AE_ERROR;
    348  1.1.1.3  christos 
    349      1.1    jruoho     if (ReturnValue.Length < sizeof (ACPI_OBJECT))
    350      1.1    jruoho     {
    351      1.1    jruoho         AcpiOsPrintf ("Return value from _OSI method too small, %.8X\n",
    352      1.1    jruoho             ReturnValue.Length);
    353  1.1.1.3  christos         goto ErrorExit;
    354      1.1    jruoho     }
    355      1.1    jruoho 
    356      1.1    jruoho     Obj = ReturnValue.Pointer;
    357      1.1    jruoho     if (Obj->Type != ACPI_TYPE_INTEGER)
    358      1.1    jruoho     {
    359      1.1    jruoho         AcpiOsPrintf ("Invalid return type from _OSI method, %.2X\n", Obj->Type);
    360  1.1.1.3  christos         goto ErrorExit;
    361      1.1    jruoho     }
    362      1.1    jruoho 
    363      1.1    jruoho     if (Obj->Integer.Value != ExpectedResult)
    364      1.1    jruoho     {
    365      1.1    jruoho         AcpiOsPrintf ("Invalid return value from _OSI, expected %.8X found %.8X\n",
    366      1.1    jruoho             ExpectedResult, (UINT32) Obj->Integer.Value);
    367  1.1.1.3  christos         goto ErrorExit;
    368      1.1    jruoho     }
    369      1.1    jruoho 
    370  1.1.1.3  christos     Status = AE_OK;
    371  1.1.1.3  christos 
    372      1.1    jruoho     /* Reset the OSI data */
    373      1.1    jruoho 
    374      1.1    jruoho     AcpiGbl_OsiData = 0;
    375  1.1.1.3  christos 
    376  1.1.1.3  christos ErrorExit:
    377  1.1.1.3  christos 
    378  1.1.1.3  christos     /* Free a buffer created via ACPI_ALLOCATE_BUFFER */
    379  1.1.1.3  christos 
    380  1.1.1.3  christos     AcpiOsFree (ReturnValue.Pointer);
    381  1.1.1.3  christos 
    382  1.1.1.3  christos     return (Status);
    383      1.1    jruoho }
    384      1.1    jruoho 
    385      1.1    jruoho 
    386      1.1    jruoho /******************************************************************************
    387      1.1    jruoho  *
    388      1.1    jruoho  * FUNCTION:    AeGenericRegisters
    389      1.1    jruoho  *
    390      1.1    jruoho  * DESCRIPTION: Call the AcpiRead/Write interfaces.
    391      1.1    jruoho  *
    392      1.1    jruoho  *****************************************************************************/
    393      1.1    jruoho 
    394  1.1.1.2    jruoho static ACPI_GENERIC_ADDRESS       GenericRegister;
    395      1.1    jruoho 
    396  1.1.1.2    jruoho static void
    397      1.1    jruoho AeGenericRegisters (
    398      1.1    jruoho     void)
    399      1.1    jruoho {
    400      1.1    jruoho     ACPI_STATUS             Status;
    401      1.1    jruoho     UINT64                  Value;
    402      1.1    jruoho 
    403      1.1    jruoho 
    404      1.1    jruoho     GenericRegister.Address = 0x1234;
    405      1.1    jruoho     GenericRegister.BitWidth = 64;
    406      1.1    jruoho     GenericRegister.BitOffset = 0;
    407      1.1    jruoho     GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
    408      1.1    jruoho 
    409      1.1    jruoho     Status = AcpiRead (&Value, &GenericRegister);
    410  1.1.1.2    jruoho     AE_CHECK_OK (AcpiRead, Status);
    411  1.1.1.2    jruoho 
    412      1.1    jruoho     Status = AcpiWrite (Value, &GenericRegister);
    413  1.1.1.2    jruoho     AE_CHECK_OK (AcpiWrite, Status);
    414      1.1    jruoho 
    415      1.1    jruoho     GenericRegister.Address = 0x12345678;
    416      1.1    jruoho     GenericRegister.BitOffset = 0;
    417      1.1    jruoho     GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY;
    418      1.1    jruoho 
    419      1.1    jruoho     Status = AcpiRead (&Value, &GenericRegister);
    420  1.1.1.2    jruoho     AE_CHECK_OK (AcpiRead, Status);
    421  1.1.1.2    jruoho 
    422      1.1    jruoho     Status = AcpiWrite (Value, &GenericRegister);
    423  1.1.1.2    jruoho     AE_CHECK_OK (AcpiWrite, Status);
    424      1.1    jruoho }
    425      1.1    jruoho 
    426      1.1    jruoho 
    427      1.1    jruoho /******************************************************************************
    428      1.1    jruoho  *
    429  1.1.1.3  christos  * FUNCTION:    AeMutexInterfaces
    430  1.1.1.3  christos  *
    431  1.1.1.3  christos  * DESCRIPTION: Exercise the AML mutex access interfaces
    432  1.1.1.3  christos  *
    433  1.1.1.3  christos  *****************************************************************************/
    434  1.1.1.3  christos 
    435  1.1.1.3  christos static void
    436  1.1.1.3  christos AeMutexInterfaces (
    437  1.1.1.3  christos     void)
    438  1.1.1.3  christos {
    439  1.1.1.3  christos     ACPI_STATUS             Status;
    440  1.1.1.3  christos     ACPI_HANDLE             MutexHandle;
    441  1.1.1.3  christos 
    442  1.1.1.3  christos 
    443  1.1.1.3  christos     /* Get a handle to an AML mutex */
    444  1.1.1.3  christos 
    445  1.1.1.3  christos     Status = AcpiGetHandle (NULL, "\\MTX1", &MutexHandle);
    446  1.1.1.3  christos     if (Status == AE_NOT_FOUND)
    447  1.1.1.3  christos     {
    448  1.1.1.3  christos         return;
    449  1.1.1.3  christos     }
    450  1.1.1.3  christos 
    451  1.1.1.3  christos     AE_CHECK_OK (AcpiGetHandle, Status);
    452  1.1.1.3  christos     if (ACPI_FAILURE (Status))
    453  1.1.1.3  christos     {
    454  1.1.1.3  christos         return;
    455  1.1.1.3  christos     }
    456  1.1.1.3  christos 
    457  1.1.1.3  christos     /* Acquire the  mutex */
    458  1.1.1.3  christos 
    459  1.1.1.3  christos     Status = AcpiAcquireMutex (NULL, "\\MTX1", 0xFFFF);
    460  1.1.1.3  christos     AE_CHECK_OK (AcpiAcquireMutex, Status);
    461  1.1.1.3  christos     if (ACPI_FAILURE (Status))
    462  1.1.1.3  christos     {
    463  1.1.1.3  christos         return;
    464  1.1.1.3  christos     }
    465  1.1.1.3  christos 
    466  1.1.1.3  christos     /* Release mutex with different parameters */
    467  1.1.1.3  christos 
    468  1.1.1.3  christos     Status = AcpiReleaseMutex (MutexHandle, NULL);
    469  1.1.1.3  christos     AE_CHECK_OK (AcpiReleaseMutex, Status);
    470  1.1.1.3  christos }
    471  1.1.1.3  christos 
    472  1.1.1.3  christos 
    473  1.1.1.3  christos /******************************************************************************
    474  1.1.1.3  christos  *
    475      1.1    jruoho  * FUNCTION:    AeHardwareInterfaces
    476      1.1    jruoho  *
    477      1.1    jruoho  * DESCRIPTION: Call various hardware support interfaces
    478      1.1    jruoho  *
    479      1.1    jruoho  *****************************************************************************/
    480      1.1    jruoho 
    481  1.1.1.2    jruoho static void
    482      1.1    jruoho AeHardwareInterfaces (
    483      1.1    jruoho     void)
    484      1.1    jruoho {
    485  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE)
    486  1.1.1.3  christos 
    487      1.1    jruoho     ACPI_STATUS             Status;
    488      1.1    jruoho     UINT32                  Value;
    489      1.1    jruoho 
    490      1.1    jruoho 
    491  1.1.1.3  christos     /* If Hardware Reduced flag is set, we are all done */
    492  1.1.1.3  christos 
    493  1.1.1.3  christos     if (AcpiGbl_ReducedHardware)
    494  1.1.1.3  christos     {
    495  1.1.1.3  christos         return;
    496  1.1.1.3  christos     }
    497  1.1.1.3  christos 
    498      1.1    jruoho     Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, 1);
    499  1.1.1.2    jruoho     AE_CHECK_OK (AcpiWriteBitRegister, Status);
    500  1.1.1.2    jruoho 
    501      1.1    jruoho     Status = AcpiWriteBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, 1);
    502  1.1.1.2    jruoho     AE_CHECK_OK (AcpiWriteBitRegister, Status);
    503  1.1.1.2    jruoho 
    504      1.1    jruoho     Status = AcpiWriteBitRegister (ACPI_BITREG_SLEEP_ENABLE, 1);
    505  1.1.1.2    jruoho     AE_CHECK_OK (AcpiWriteBitRegister, Status);
    506  1.1.1.2    jruoho 
    507      1.1    jruoho     Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1);
    508  1.1.1.2    jruoho     AE_CHECK_OK (AcpiWriteBitRegister, Status);
    509  1.1.1.2    jruoho 
    510      1.1    jruoho 
    511      1.1    jruoho     Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &Value);
    512  1.1.1.2    jruoho     AE_CHECK_OK (AcpiReadBitRegister, Status);
    513  1.1.1.2    jruoho 
    514      1.1    jruoho     Status = AcpiReadBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, &Value);
    515  1.1.1.2    jruoho     AE_CHECK_OK (AcpiReadBitRegister, Status);
    516  1.1.1.2    jruoho 
    517      1.1    jruoho     Status = AcpiReadBitRegister (ACPI_BITREG_SLEEP_ENABLE, &Value);
    518  1.1.1.2    jruoho     AE_CHECK_OK (AcpiReadBitRegister, Status);
    519  1.1.1.2    jruoho 
    520      1.1    jruoho     Status = AcpiReadBitRegister (ACPI_BITREG_ARB_DISABLE, &Value);
    521  1.1.1.2    jruoho     AE_CHECK_OK (AcpiReadBitRegister, Status);
    522  1.1.1.3  christos 
    523  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    524      1.1    jruoho }
    525      1.1    jruoho 
    526      1.1    jruoho 
    527      1.1    jruoho /******************************************************************************
    528      1.1    jruoho  *
    529      1.1    jruoho  * FUNCTION:    AeMiscellaneousTests
    530      1.1    jruoho  *
    531      1.1    jruoho  * DESCRIPTION: Various ACPICA validation tests.
    532      1.1    jruoho  *
    533      1.1    jruoho  *****************************************************************************/
    534      1.1    jruoho 
    535      1.1    jruoho void
    536      1.1    jruoho AeMiscellaneousTests (
    537      1.1    jruoho     void)
    538      1.1    jruoho {
    539      1.1    jruoho     ACPI_BUFFER             ReturnBuf;
    540      1.1    jruoho     char                    Buffer[32];
    541      1.1    jruoho     ACPI_STATUS             Status;
    542  1.1.1.3  christos     ACPI_STATISTICS         Stats;
    543  1.1.1.3  christos     ACPI_HANDLE             Handle;
    544  1.1.1.3  christos 
    545  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE)
    546  1.1.1.3  christos     ACPI_VENDOR_UUID        Uuid = {0, {ACPI_INIT_UUID (0,0,0,0,0,0,0,0,0,0,0)}};
    547      1.1    jruoho     UINT32                  LockHandle1;
    548      1.1    jruoho     UINT32                  LockHandle2;
    549  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    550  1.1.1.3  christos 
    551  1.1.1.3  christos 
    552  1.1.1.3  christos     Status = AcpiGetHandle (NULL, "\\", &Handle);
    553  1.1.1.3  christos     AE_CHECK_OK (AcpiGetHandle, Status);
    554  1.1.1.3  christos 
    555  1.1.1.3  christos     if (AcpiGbl_DoInterfaceTests)
    556  1.1.1.3  christos     {
    557  1.1.1.3  christos         /*
    558  1.1.1.3  christos          * Tests for AcpiLoadTable and AcpiUnloadParentTable
    559  1.1.1.3  christos          */
    560  1.1.1.3  christos 
    561  1.1.1.3  christos         /* Attempt unload of DSDT, should fail */
    562  1.1.1.3  christos 
    563  1.1.1.3  christos         Status = AcpiGetHandle (NULL, "\\_SB_", &Handle);
    564  1.1.1.3  christos         AE_CHECK_OK (AcpiGetHandle, Status);
    565  1.1.1.3  christos 
    566  1.1.1.3  christos         Status = AcpiUnloadParentTable (Handle);
    567  1.1.1.3  christos         AE_CHECK_STATUS (AcpiUnloadParentTable, Status, AE_TYPE);
    568      1.1    jruoho 
    569  1.1.1.3  christos         /* Load and unload SSDT4 */
    570  1.1.1.3  christos 
    571  1.1.1.3  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code);
    572  1.1.1.3  christos         AE_CHECK_OK (AcpiLoadTable, Status);
    573  1.1.1.3  christos 
    574  1.1.1.3  christos         Status = AcpiGetHandle (NULL, "\\_T96", &Handle);
    575  1.1.1.3  christos         AE_CHECK_OK (AcpiGetHandle, Status);
    576  1.1.1.3  christos 
    577  1.1.1.3  christos         Status = AcpiUnloadParentTable (Handle);
    578  1.1.1.3  christos         AE_CHECK_OK (AcpiUnloadParentTable, Status);
    579  1.1.1.3  christos 
    580  1.1.1.3  christos         /* Re-load SSDT4 */
    581  1.1.1.3  christos 
    582  1.1.1.3  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code);
    583  1.1.1.3  christos         AE_CHECK_OK (AcpiLoadTable, Status);
    584  1.1.1.3  christos 
    585  1.1.1.3  christos         /* Unload and re-load SSDT2 (SSDT2 is in the XSDT) */
    586  1.1.1.3  christos 
    587  1.1.1.3  christos         Status = AcpiGetHandle (NULL, "\\_T99", &Handle);
    588  1.1.1.3  christos         AE_CHECK_OK (AcpiGetHandle, Status);
    589  1.1.1.3  christos 
    590  1.1.1.3  christos         Status = AcpiUnloadParentTable (Handle);
    591  1.1.1.3  christos         AE_CHECK_OK (AcpiUnloadParentTable, Status);
    592  1.1.1.3  christos 
    593  1.1.1.3  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt2Code);
    594  1.1.1.3  christos         AE_CHECK_OK (AcpiLoadTable, Status);
    595  1.1.1.3  christos 
    596  1.1.1.3  christos         /* Load OEM9 table (causes table override) */
    597  1.1.1.3  christos 
    598  1.1.1.3  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt3Code);
    599  1.1.1.3  christos         AE_CHECK_OK (AcpiLoadTable, Status);
    600  1.1.1.3  christos     }
    601      1.1    jruoho 
    602      1.1    jruoho     AeHardwareInterfaces ();
    603      1.1    jruoho     AeGenericRegisters ();
    604      1.1    jruoho     AeSetupConfiguration (Ssdt3Code);
    605      1.1    jruoho 
    606      1.1    jruoho     AeTestBufferArgument();
    607      1.1    jruoho     AeTestPackageArgument ();
    608  1.1.1.3  christos     AeMutexInterfaces ();
    609  1.1.1.2    jruoho 
    610  1.1.1.3  christos     /* Test _OSI install/remove */
    611  1.1.1.2    jruoho 
    612  1.1.1.2    jruoho     Status = AcpiInstallInterface ("");
    613  1.1.1.2    jruoho     AE_CHECK_STATUS (AcpiInstallInterface, Status, AE_BAD_PARAMETER);
    614  1.1.1.2    jruoho 
    615  1.1.1.2    jruoho     Status = AcpiInstallInterface ("TestString");
    616  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallInterface, Status);
    617  1.1.1.2    jruoho 
    618  1.1.1.2    jruoho     Status = AcpiInstallInterface ("TestString");
    619  1.1.1.2    jruoho     AE_CHECK_STATUS (AcpiInstallInterface, Status, AE_ALREADY_EXISTS);
    620  1.1.1.2    jruoho 
    621  1.1.1.2    jruoho     Status = AcpiRemoveInterface ("Windows 2006");
    622  1.1.1.2    jruoho     AE_CHECK_OK (AcpiRemoveInterface, Status);
    623  1.1.1.2    jruoho 
    624  1.1.1.2    jruoho     Status = AcpiRemoveInterface ("TestString");
    625  1.1.1.2    jruoho     AE_CHECK_OK (AcpiRemoveInterface, Status);
    626  1.1.1.2    jruoho 
    627  1.1.1.2    jruoho     Status = AcpiRemoveInterface ("XXXXXX");
    628  1.1.1.2    jruoho     AE_CHECK_STATUS (AcpiRemoveInterface, Status, AE_NOT_EXIST);
    629  1.1.1.2    jruoho 
    630  1.1.1.2    jruoho     Status = AcpiInstallInterface ("AnotherTestString");
    631  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallInterface, Status);
    632  1.1.1.2    jruoho 
    633  1.1.1.3  christos     /* Test _OSI execution */
    634  1.1.1.3  christos 
    635  1.1.1.3  christos     Status = ExecuteOSI ("Extended Address Space Descriptor", 0xFFFFFFFF);
    636  1.1.1.3  christos     AE_CHECK_OK (ExecuteOSI, Status);
    637  1.1.1.2    jruoho 
    638  1.1.1.2    jruoho     Status = ExecuteOSI ("Windows 2001", 0xFFFFFFFF);
    639  1.1.1.2    jruoho     AE_CHECK_OK (ExecuteOSI, Status);
    640  1.1.1.2    jruoho 
    641  1.1.1.2    jruoho     Status = ExecuteOSI ("MichiganTerminalSystem", 0);
    642  1.1.1.2    jruoho     AE_CHECK_OK (ExecuteOSI, Status);
    643      1.1    jruoho 
    644      1.1    jruoho 
    645      1.1    jruoho     ReturnBuf.Length = 32;
    646      1.1    jruoho     ReturnBuf.Pointer = Buffer;
    647      1.1    jruoho 
    648  1.1.1.3  christos     Status = AcpiGetName (ACPI_ROOT_OBJECT, ACPI_FULL_PATHNAME, &ReturnBuf);
    649  1.1.1.2    jruoho     AE_CHECK_OK (AcpiGetName, Status);
    650  1.1.1.2    jruoho 
    651  1.1.1.3  christos     /* Get Devices */
    652  1.1.1.3  christos 
    653  1.1.1.3  christos     Status = AcpiGetDevices (NULL, AeGetDevices, NULL, NULL);
    654  1.1.1.3  christos     AE_CHECK_OK (AcpiGetDevices, Status);
    655  1.1.1.3  christos 
    656  1.1.1.3  christos     Status = AcpiGetStatistics (&Stats);
    657  1.1.1.3  christos     AE_CHECK_OK (AcpiGetStatistics, Status);
    658  1.1.1.3  christos 
    659  1.1.1.3  christos 
    660  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE)
    661  1.1.1.2    jruoho 
    662  1.1.1.2    jruoho     Status = AcpiInstallGlobalEventHandler (AeGlobalEventHandler, NULL);
    663  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGlobalEventHandler, Status);
    664      1.1    jruoho 
    665  1.1.1.3  christos     /* If Hardware Reduced flag is set, we are all done */
    666  1.1.1.3  christos 
    667  1.1.1.3  christos     if (AcpiGbl_ReducedHardware)
    668  1.1.1.3  christos     {
    669  1.1.1.3  christos         return;
    670  1.1.1.3  christos     }
    671  1.1.1.3  christos 
    672  1.1.1.3  christos     Status = AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0);
    673  1.1.1.3  christos     AE_CHECK_OK (AcpiEnableEvent, Status);
    674  1.1.1.3  christos 
    675      1.1    jruoho     /*
    676      1.1    jruoho      * GPEs: Handlers, enable/disable, etc.
    677      1.1    jruoho      */
    678  1.1.1.2    jruoho     Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    679  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    680  1.1.1.2    jruoho 
    681  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 0);
    682  1.1.1.2    jruoho     AE_CHECK_OK (AcpiEnableGpe, Status);
    683  1.1.1.2    jruoho 
    684  1.1.1.2    jruoho     Status = AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler);
    685  1.1.1.2    jruoho     AE_CHECK_OK (AcpiRemoveGpeHandler, Status);
    686  1.1.1.2    jruoho 
    687  1.1.1.2    jruoho     Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    688  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    689  1.1.1.2    jruoho 
    690  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 0);
    691  1.1.1.2    jruoho     AE_CHECK_OK (AcpiEnableGpe, Status);
    692  1.1.1.2    jruoho 
    693  1.1.1.2    jruoho     Status = AcpiSetGpe (NULL, 0, ACPI_GPE_DISABLE);
    694  1.1.1.2    jruoho     AE_CHECK_OK (AcpiSetGpe, Status);
    695  1.1.1.2    jruoho 
    696  1.1.1.2    jruoho     Status = AcpiSetGpe (NULL, 0, ACPI_GPE_ENABLE);
    697  1.1.1.2    jruoho     AE_CHECK_OK (AcpiSetGpe, Status);
    698  1.1.1.2    jruoho 
    699  1.1.1.2    jruoho 
    700  1.1.1.2    jruoho     Status = AcpiInstallGpeHandler (NULL, 1, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
    701  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    702  1.1.1.2    jruoho 
    703  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 1);
    704  1.1.1.2    jruoho     AE_CHECK_OK (AcpiEnableGpe, Status);
    705  1.1.1.2    jruoho 
    706  1.1.1.2    jruoho 
    707  1.1.1.2    jruoho     Status = AcpiInstallGpeHandler (NULL, 2, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    708  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    709  1.1.1.2    jruoho 
    710  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 2);
    711  1.1.1.2    jruoho     AE_CHECK_OK (AcpiEnableGpe, Status);
    712  1.1.1.2    jruoho 
    713  1.1.1.2    jruoho 
    714  1.1.1.2    jruoho     Status = AcpiInstallGpeHandler (NULL, 3, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
    715  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    716  1.1.1.2    jruoho 
    717  1.1.1.2    jruoho     Status = AcpiInstallGpeHandler (NULL, 4, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    718  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    719  1.1.1.2    jruoho 
    720  1.1.1.2    jruoho     Status = AcpiInstallGpeHandler (NULL, 5, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
    721  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    722  1.1.1.2    jruoho 
    723  1.1.1.2    jruoho     Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
    724  1.1.1.2    jruoho     AE_CHECK_OK (AcpiGetHandle, Status);
    725  1.1.1.2    jruoho 
    726  1.1.1.2    jruoho     Status = AcpiSetupGpeForWake (Handle, NULL, 5);
    727  1.1.1.2    jruoho     AE_CHECK_OK (AcpiSetupGpeForWake, Status);
    728  1.1.1.2    jruoho 
    729  1.1.1.2    jruoho     Status = AcpiSetGpeWakeMask (NULL, 5, ACPI_GPE_ENABLE);
    730  1.1.1.3  christos     AE_CHECK_OK (AcpiSetGpeWakeMask, Status);
    731  1.1.1.2    jruoho 
    732  1.1.1.2    jruoho     Status = AcpiSetupGpeForWake (Handle, NULL, 6);
    733  1.1.1.2    jruoho     AE_CHECK_OK (AcpiSetupGpeForWake, Status);
    734  1.1.1.2    jruoho 
    735  1.1.1.3  christos     Status = AcpiSetupGpeForWake (ACPI_ROOT_OBJECT, NULL, 6);
    736  1.1.1.3  christos     AE_CHECK_OK (AcpiSetupGpeForWake, Status);
    737  1.1.1.3  christos 
    738  1.1.1.2    jruoho     Status = AcpiSetupGpeForWake (Handle, NULL, 9);
    739  1.1.1.2    jruoho     AE_CHECK_OK (AcpiSetupGpeForWake, Status);
    740  1.1.1.2    jruoho 
    741  1.1.1.2    jruoho     Status = AcpiInstallGpeHandler (NULL, 0x19, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    742  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    743  1.1.1.2    jruoho 
    744  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 0x19);
    745  1.1.1.2    jruoho     AE_CHECK_OK (AcpiEnableGpe, Status);
    746  1.1.1.2    jruoho 
    747  1.1.1.2    jruoho 
    748  1.1.1.2    jruoho     Status = AcpiInstallGpeHandler (NULL, 0x62, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    749  1.1.1.2    jruoho     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
    750  1.1.1.2    jruoho 
    751  1.1.1.2    jruoho     Status = AcpiEnableGpe (NULL, 0x62);
    752  1.1.1.2    jruoho     AE_CHECK_OK (AcpiEnableGpe, Status);
    753  1.1.1.2    jruoho 
    754  1.1.1.2    jruoho     Status = AcpiDisableGpe (NULL, 0x62);
    755  1.1.1.2    jruoho     AE_CHECK_OK (AcpiDisableGpe, Status);
    756      1.1    jruoho 
    757      1.1    jruoho     AfInstallGpeBlock ();
    758      1.1    jruoho 
    759  1.1.1.2    jruoho     /* Here is where the GPEs are actually "enabled" */
    760  1.1.1.2    jruoho 
    761  1.1.1.2    jruoho     Status = AcpiUpdateAllGpes ();
    762  1.1.1.2    jruoho     AE_CHECK_OK (AcpiUpdateAllGpes, Status);
    763      1.1    jruoho 
    764      1.1    jruoho     Status = AcpiGetHandle (NULL, "RSRC", &Handle);
    765      1.1    jruoho     if (ACPI_SUCCESS (Status))
    766      1.1    jruoho     {
    767      1.1    jruoho         ReturnBuf.Length = ACPI_ALLOCATE_BUFFER;
    768      1.1    jruoho 
    769      1.1    jruoho         Status = AcpiGetVendorResource (Handle, "_CRS", &Uuid, &ReturnBuf);
    770      1.1    jruoho         if (ACPI_SUCCESS (Status))
    771      1.1    jruoho         {
    772      1.1    jruoho             AcpiOsFree (ReturnBuf.Pointer);
    773      1.1    jruoho         }
    774      1.1    jruoho     }
    775      1.1    jruoho 
    776      1.1    jruoho     /* Test global lock */
    777      1.1    jruoho 
    778      1.1    jruoho     Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1);
    779  1.1.1.2    jruoho     AE_CHECK_OK (AcpiAcquireGlobalLock, Status);
    780      1.1    jruoho 
    781      1.1    jruoho     Status = AcpiAcquireGlobalLock (0x5, &LockHandle2);
    782  1.1.1.2    jruoho     AE_CHECK_OK (AcpiAcquireGlobalLock, Status);
    783      1.1    jruoho 
    784      1.1    jruoho     Status = AcpiReleaseGlobalLock (LockHandle1);
    785  1.1.1.2    jruoho     AE_CHECK_OK (AcpiReleaseGlobalLock, Status);
    786      1.1    jruoho 
    787      1.1    jruoho     Status = AcpiReleaseGlobalLock (LockHandle2);
    788  1.1.1.2    jruoho     AE_CHECK_OK (AcpiReleaseGlobalLock, Status);
    789      1.1    jruoho 
    790  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    791      1.1    jruoho }
    792