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