Home | History | Annotate | Line # | Download | only in acpiexec
aetests.c revision 1.1.1.6.4.1
      1          1.1  christos /******************************************************************************
      2          1.1  christos  *
      3          1.1  christos  * Module Name: aetests - Miscellaneous tests for ACPICA public interfaces
      4          1.1  christos  *
      5          1.1  christos  *****************************************************************************/
      6          1.1  christos 
      7          1.1  christos /*
      8  1.1.1.6.4.1   thorpej  * Copyright (C) 2000 - 2021, Intel Corp.
      9          1.1  christos  * All rights reserved.
     10          1.1  christos  *
     11          1.1  christos  * Redistribution and use in source and binary forms, with or without
     12          1.1  christos  * modification, are permitted provided that the following conditions
     13          1.1  christos  * are met:
     14          1.1  christos  * 1. Redistributions of source code must retain the above copyright
     15          1.1  christos  *    notice, this list of conditions, and the following disclaimer,
     16          1.1  christos  *    without modification.
     17          1.1  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18          1.1  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
     19          1.1  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
     20          1.1  christos  *    including a substantially similar Disclaimer requirement for further
     21          1.1  christos  *    binary redistribution.
     22          1.1  christos  * 3. Neither the names of the above-listed copyright holders nor the names
     23          1.1  christos  *    of any contributors may be used to endorse or promote products derived
     24          1.1  christos  *    from this software without specific prior written permission.
     25          1.1  christos  *
     26          1.1  christos  * Alternatively, this software may be distributed under the terms of the
     27          1.1  christos  * GNU General Public License ("GPL") version 2 as published by the Free
     28          1.1  christos  * Software Foundation.
     29          1.1  christos  *
     30          1.1  christos  * NO WARRANTY
     31          1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32          1.1  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.6.4.1   thorpej  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     34          1.1  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35          1.1  christos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36          1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37          1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38          1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39          1.1  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40          1.1  christos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41          1.1  christos  * POSSIBILITY OF SUCH DAMAGES.
     42          1.1  christos  */
     43          1.1  christos 
     44          1.1  christos #include "aecommon.h"
     45          1.1  christos 
     46          1.1  christos #define _COMPONENT          ACPI_TOOLS
     47          1.1  christos         ACPI_MODULE_NAME    ("aetests")
     48          1.1  christos 
     49          1.1  christos /* Local prototypes */
     50          1.1  christos 
     51          1.1  christos static void
     52          1.1  christos AeMutexInterfaces (
     53          1.1  christos     void);
     54          1.1  christos 
     55          1.1  christos static void
     56          1.1  christos AeHardwareInterfaces (
     57          1.1  christos     void);
     58          1.1  christos 
     59          1.1  christos static void
     60          1.1  christos AeTestSleepData (
     61          1.1  christos     void);
     62          1.1  christos 
     63      1.1.1.3  christos static void
     64      1.1.1.3  christos AeGlobalAddressRangeCheck(
     65      1.1.1.3  christos     void);
     66      1.1.1.3  christos 
     67          1.1  christos 
     68          1.1  christos /******************************************************************************
     69          1.1  christos  *
     70          1.1  christos  * FUNCTION:    AeMiscellaneousTests
     71          1.1  christos  *
     72          1.1  christos  * DESCRIPTION: Various ACPICA validation tests.
     73          1.1  christos  *
     74          1.1  christos  *****************************************************************************/
     75          1.1  christos 
     76          1.1  christos void
     77          1.1  christos AeMiscellaneousTests (
     78          1.1  christos     void)
     79          1.1  christos {
     80          1.1  christos     ACPI_BUFFER             ReturnBuf;
     81          1.1  christos     char                    Buffer[32];
     82          1.1  christos     ACPI_STATUS             Status;
     83          1.1  christos     ACPI_STATISTICS         Stats;
     84          1.1  christos     ACPI_HANDLE             Handle;
     85      1.1.1.5  christos     UINT32                  TableIndex;
     86          1.1  christos 
     87          1.1  christos #if (!ACPI_REDUCED_HARDWARE)
     88          1.1  christos     UINT32                  Temp;
     89          1.1  christos     UINT32                  LockHandle1;
     90          1.1  christos     UINT32                  LockHandle2;
     91          1.1  christos     ACPI_VENDOR_UUID        Uuid = {0, {ACPI_INIT_UUID (0,0,0,0,0,0,0,0,0,0,0)}};
     92          1.1  christos #endif /* !ACPI_REDUCED_HARDWARE */
     93          1.1  christos 
     94          1.1  christos 
     95          1.1  christos     Status = AcpiGetHandle (NULL, "\\", &Handle);
     96          1.1  christos     ACPI_CHECK_OK (AcpiGetHandle, Status);
     97          1.1  christos 
     98          1.1  christos     if (AcpiGbl_DoInterfaceTests)
     99          1.1  christos     {
    100          1.1  christos         /*
    101          1.1  christos          * Tests for AcpiLoadTable and AcpiUnloadParentTable
    102          1.1  christos          */
    103          1.1  christos 
    104          1.1  christos         /* Attempt unload of DSDT, should fail */
    105          1.1  christos 
    106          1.1  christos         Status = AcpiGetHandle (NULL, "\\_SB_", &Handle);
    107          1.1  christos         ACPI_CHECK_OK (AcpiGetHandle, Status);
    108          1.1  christos 
    109          1.1  christos         Status = AcpiUnloadParentTable (Handle);
    110          1.1  christos         ACPI_CHECK_STATUS (AcpiUnloadParentTable, Status, AE_TYPE);
    111          1.1  christos 
    112          1.1  christos         /* Load and unload SSDT4 */
    113          1.1  christos 
    114      1.1.1.5  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code, &TableIndex);
    115          1.1  christos         ACPI_CHECK_OK (AcpiLoadTable, Status);
    116          1.1  christos 
    117      1.1.1.5  christos         Status = AcpiUnloadTable (TableIndex);
    118      1.1.1.5  christos         ACPI_CHECK_OK (AcpiUnloadTable, Status);
    119          1.1  christos 
    120          1.1  christos         /* Re-load SSDT4 */
    121          1.1  christos 
    122      1.1.1.5  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code, NULL);
    123          1.1  christos         ACPI_CHECK_OK (AcpiLoadTable, Status);
    124          1.1  christos 
    125          1.1  christos         /* Unload and re-load SSDT2 (SSDT2 is in the XSDT) */
    126          1.1  christos 
    127          1.1  christos         Status = AcpiGetHandle (NULL, "\\_T99", &Handle);
    128          1.1  christos         ACPI_CHECK_OK (AcpiGetHandle, Status);
    129          1.1  christos 
    130          1.1  christos         Status = AcpiUnloadParentTable (Handle);
    131          1.1  christos         ACPI_CHECK_OK (AcpiUnloadParentTable, Status);
    132          1.1  christos 
    133      1.1.1.5  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt2Code, NULL);
    134          1.1  christos         ACPI_CHECK_OK (AcpiLoadTable, Status);
    135          1.1  christos 
    136          1.1  christos         /* Load OEM9 table (causes table override) */
    137          1.1  christos 
    138      1.1.1.5  christos         Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt3Code, NULL);
    139          1.1  christos         ACPI_CHECK_OK (AcpiLoadTable, Status);
    140          1.1  christos     }
    141          1.1  christos 
    142          1.1  christos     AeHardwareInterfaces ();
    143          1.1  christos     AeGenericRegisters ();
    144          1.1  christos     AeSetupConfiguration (Ssdt3Code);
    145          1.1  christos 
    146          1.1  christos     AeTestBufferArgument();
    147          1.1  christos     AeTestPackageArgument ();
    148          1.1  christos     AeMutexInterfaces ();
    149          1.1  christos     AeTestSleepData ();
    150          1.1  christos 
    151          1.1  christos     /* Test _OSI install/remove */
    152          1.1  christos 
    153          1.1  christos     Status = AcpiInstallInterface ("");
    154          1.1  christos     ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_BAD_PARAMETER);
    155          1.1  christos 
    156          1.1  christos     Status = AcpiInstallInterface ("TestString");
    157          1.1  christos     ACPI_CHECK_OK (AcpiInstallInterface, Status);
    158          1.1  christos 
    159          1.1  christos     Status = AcpiInstallInterface ("TestString");
    160          1.1  christos     ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_ALREADY_EXISTS);
    161          1.1  christos 
    162          1.1  christos     Status = AcpiRemoveInterface ("Windows 2006");
    163          1.1  christos     ACPI_CHECK_OK (AcpiRemoveInterface, Status);
    164          1.1  christos 
    165          1.1  christos     Status = AcpiRemoveInterface ("TestString");
    166          1.1  christos     ACPI_CHECK_OK (AcpiRemoveInterface, Status);
    167          1.1  christos 
    168          1.1  christos     Status = AcpiRemoveInterface ("XXXXXX");
    169          1.1  christos     ACPI_CHECK_STATUS (AcpiRemoveInterface, Status, AE_NOT_EXIST);
    170          1.1  christos 
    171          1.1  christos     Status = AcpiInstallInterface ("AnotherTestString");
    172          1.1  christos     ACPI_CHECK_OK (AcpiInstallInterface, Status);
    173          1.1  christos 
    174          1.1  christos     /* Test _OSI execution */
    175          1.1  christos 
    176          1.1  christos     Status = ExecuteOSI ("Extended Address Space Descriptor", ACPI_UINT64_MAX);
    177          1.1  christos     ACPI_CHECK_OK (ExecuteOSI, Status);
    178          1.1  christos 
    179          1.1  christos     Status = ExecuteOSI ("Windows 2001", ACPI_UINT64_MAX);
    180          1.1  christos     ACPI_CHECK_OK (ExecuteOSI, Status);
    181          1.1  christos 
    182          1.1  christos     Status = ExecuteOSI ("MichiganTerminalSystem", 0);
    183          1.1  christos     ACPI_CHECK_OK (ExecuteOSI, Status);
    184          1.1  christos 
    185          1.1  christos 
    186          1.1  christos     ReturnBuf.Length = 32;
    187          1.1  christos     ReturnBuf.Pointer = Buffer;
    188          1.1  christos 
    189          1.1  christos     Status = AcpiGetName (ACPI_ROOT_OBJECT,
    190          1.1  christos         ACPI_FULL_PATHNAME_NO_TRAILING, &ReturnBuf);
    191          1.1  christos     ACPI_CHECK_OK (AcpiGetName, Status);
    192          1.1  christos 
    193          1.1  christos     /* Get Devices */
    194          1.1  christos 
    195          1.1  christos     Status = AcpiGetDevices (NULL, AeGetDevices, NULL, NULL);
    196          1.1  christos     ACPI_CHECK_OK (AcpiGetDevices, Status);
    197          1.1  christos 
    198          1.1  christos     Status = AcpiGetStatistics (&Stats);
    199          1.1  christos     ACPI_CHECK_OK (AcpiGetStatistics, Status);
    200          1.1  christos 
    201          1.1  christos 
    202          1.1  christos #if (!ACPI_REDUCED_HARDWARE)
    203          1.1  christos 
    204          1.1  christos     Status = AcpiInstallGlobalEventHandler (AeGlobalEventHandler, NULL);
    205          1.1  christos     ACPI_CHECK_OK (AcpiInstallGlobalEventHandler, Status);
    206          1.1  christos 
    207          1.1  christos     /* If Hardware Reduced flag is set, we are all done */
    208          1.1  christos 
    209          1.1  christos     if (AcpiGbl_ReducedHardware)
    210          1.1  christos     {
    211          1.1  christos         return;
    212          1.1  christos     }
    213          1.1  christos 
    214          1.1  christos     Status = AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0);
    215          1.1  christos     ACPI_CHECK_OK (AcpiEnableEvent, Status);
    216          1.1  christos 
    217          1.1  christos     /*
    218          1.1  christos      * GPEs: Handlers, enable/disable, etc.
    219          1.1  christos      */
    220          1.1  christos     Status = AcpiInstallGpeHandler (NULL, 0,
    221          1.1  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    222          1.1  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    223          1.1  christos 
    224          1.1  christos     Status = AcpiEnableGpe (NULL, 0);
    225          1.1  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    226          1.1  christos 
    227          1.1  christos     Status = AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler);
    228          1.1  christos     ACPI_CHECK_OK (AcpiRemoveGpeHandler, Status);
    229          1.1  christos 
    230          1.1  christos     Status = AcpiInstallGpeHandler (NULL, 0,
    231          1.1  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    232          1.1  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    233          1.1  christos 
    234          1.1  christos     Status = AcpiEnableGpe (NULL, 0);
    235          1.1  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    236          1.1  christos 
    237          1.1  christos     Status = AcpiSetGpe (NULL, 0, ACPI_GPE_DISABLE);
    238          1.1  christos     ACPI_CHECK_OK (AcpiSetGpe, Status);
    239          1.1  christos 
    240          1.1  christos     Status = AcpiSetGpe (NULL, 0, ACPI_GPE_ENABLE);
    241          1.1  christos     ACPI_CHECK_OK (AcpiSetGpe, Status);
    242          1.1  christos 
    243          1.1  christos 
    244          1.1  christos     Status = AcpiInstallGpeHandler (NULL, 1,
    245          1.1  christos         ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
    246          1.1  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    247          1.1  christos 
    248          1.1  christos     Status = AcpiEnableGpe (NULL, 1);
    249          1.1  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    250          1.1  christos 
    251          1.1  christos 
    252          1.1  christos     Status = AcpiInstallGpeHandler (NULL, 2,
    253          1.1  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    254          1.1  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    255          1.1  christos 
    256          1.1  christos     Status = AcpiEnableGpe (NULL, 2);
    257          1.1  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    258          1.1  christos 
    259          1.1  christos 
    260          1.1  christos     Status = AcpiInstallGpeHandler (NULL, 3,
    261          1.1  christos         ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
    262          1.1  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    263          1.1  christos 
    264          1.1  christos     Status = AcpiInstallGpeHandler (NULL, 4,
    265          1.1  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    266          1.1  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    267          1.1  christos 
    268          1.1  christos     Status = AcpiInstallGpeHandler (NULL, 5,
    269          1.1  christos         ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
    270          1.1  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    271          1.1  christos 
    272          1.1  christos     Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
    273          1.1  christos     ACPI_CHECK_OK (AcpiGetHandle, Status);
    274          1.1  christos 
    275          1.1  christos     Status = AcpiSetupGpeForWake (Handle, NULL, 5);
    276          1.1  christos     ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
    277          1.1  christos 
    278          1.1  christos     Status = AcpiSetGpeWakeMask (NULL, 5, ACPI_GPE_ENABLE);
    279          1.1  christos     ACPI_CHECK_OK (AcpiSetGpeWakeMask, Status);
    280          1.1  christos 
    281          1.1  christos     Status = AcpiSetupGpeForWake (Handle, NULL, 6);
    282          1.1  christos     ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
    283          1.1  christos 
    284          1.1  christos     Status = AcpiSetupGpeForWake (ACPI_ROOT_OBJECT, NULL, 6);
    285          1.1  christos     ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
    286          1.1  christos 
    287          1.1  christos     Status = AcpiSetupGpeForWake (Handle, NULL, 9);
    288          1.1  christos     ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
    289          1.1  christos 
    290          1.1  christos     Status = AcpiInstallGpeHandler (NULL, 0x19,
    291          1.1  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    292          1.1  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    293          1.1  christos 
    294          1.1  christos     Status = AcpiEnableGpe (NULL, 0x19);
    295          1.1  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    296          1.1  christos 
    297          1.1  christos 
    298          1.1  christos     /* GPE block 1 */
    299          1.1  christos 
    300          1.1  christos     Status = AcpiInstallGpeHandler (NULL, 101,
    301          1.1  christos         ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
    302          1.1  christos     ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
    303          1.1  christos 
    304          1.1  christos     Status = AcpiEnableGpe (NULL, 101);
    305          1.1  christos     ACPI_CHECK_OK (AcpiEnableGpe, Status);
    306          1.1  christos 
    307          1.1  christos     Status = AcpiDisableGpe (NULL, 101);
    308          1.1  christos     ACPI_CHECK_OK (AcpiDisableGpe, Status);
    309          1.1  christos 
    310          1.1  christos     AfInstallGpeBlock ();
    311          1.1  christos 
    312          1.1  christos     /* Here is where the GPEs are actually "enabled" */
    313          1.1  christos 
    314          1.1  christos     Status = AcpiUpdateAllGpes ();
    315          1.1  christos     ACPI_CHECK_OK (AcpiUpdateAllGpes, Status);
    316          1.1  christos 
    317          1.1  christos     Status = AcpiGetHandle (NULL, "RSRC", &Handle);
    318          1.1  christos     if (ACPI_SUCCESS (Status))
    319          1.1  christos     {
    320          1.1  christos         ReturnBuf.Length = ACPI_ALLOCATE_BUFFER;
    321          1.1  christos 
    322          1.1  christos         Status = AcpiGetVendorResource (Handle, "_CRS", &Uuid, &ReturnBuf);
    323          1.1  christos         if (ACPI_SUCCESS (Status))
    324          1.1  christos         {
    325          1.1  christos             AcpiOsFree (ReturnBuf.Pointer);
    326          1.1  christos         }
    327          1.1  christos     }
    328          1.1  christos 
    329          1.1  christos     /* Test global lock */
    330          1.1  christos 
    331          1.1  christos     Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1);
    332          1.1  christos     ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status);
    333          1.1  christos 
    334          1.1  christos     Status = AcpiAcquireGlobalLock (0x5, &LockHandle2);
    335          1.1  christos     ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status);
    336          1.1  christos 
    337          1.1  christos     Status = AcpiReleaseGlobalLock (LockHandle1);
    338          1.1  christos     ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status);
    339          1.1  christos 
    340          1.1  christos     Status = AcpiReleaseGlobalLock (LockHandle2);
    341          1.1  christos     ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status);
    342          1.1  christos 
    343          1.1  christos     /* Test timer interfaces */
    344          1.1  christos 
    345          1.1  christos     Status = AcpiGetTimerResolution (&Temp);
    346          1.1  christos     ACPI_CHECK_OK (AcpiGetTimerResolution, Status);
    347          1.1  christos 
    348          1.1  christos     Status = AcpiGetTimer (&Temp);
    349          1.1  christos     ACPI_CHECK_OK (AcpiGetTimer, Status);
    350          1.1  christos 
    351          1.1  christos     Status = AcpiGetTimerDuration (0x1000, 0x2000, &Temp);
    352          1.1  christos     ACPI_CHECK_OK (AcpiGetTimerDuration, Status);
    353          1.1  christos 
    354          1.1  christos 
    355          1.1  christos #endif /* !ACPI_REDUCED_HARDWARE */
    356          1.1  christos }
    357          1.1  christos 
    358          1.1  christos 
    359          1.1  christos /******************************************************************************
    360          1.1  christos  *
    361          1.1  christos  * FUNCTION:    AeMutexInterfaces
    362          1.1  christos  *
    363          1.1  christos  * DESCRIPTION: Exercise the AML mutex access interfaces
    364          1.1  christos  *
    365          1.1  christos  *****************************************************************************/
    366          1.1  christos 
    367          1.1  christos static void
    368          1.1  christos AeMutexInterfaces (
    369          1.1  christos     void)
    370          1.1  christos {
    371          1.1  christos     ACPI_STATUS             Status;
    372          1.1  christos     ACPI_HANDLE             MutexHandle;
    373          1.1  christos 
    374          1.1  christos 
    375          1.1  christos     /* Get a handle to an AML mutex */
    376          1.1  christos 
    377          1.1  christos     Status = AcpiGetHandle (NULL, "\\MTX1", &MutexHandle);
    378          1.1  christos     if (Status == AE_NOT_FOUND)
    379          1.1  christos     {
    380          1.1  christos         return;
    381          1.1  christos     }
    382          1.1  christos 
    383          1.1  christos     ACPI_CHECK_OK (AcpiGetHandle, Status);
    384          1.1  christos     if (ACPI_FAILURE (Status))
    385          1.1  christos     {
    386          1.1  christos         return;
    387          1.1  christos     }
    388          1.1  christos 
    389          1.1  christos     /* Acquire the  mutex */
    390          1.1  christos 
    391          1.1  christos     Status = AcpiAcquireMutex (NULL, "\\MTX1", 0xFFFF);
    392          1.1  christos     ACPI_CHECK_OK (AcpiAcquireMutex, Status);
    393          1.1  christos     if (ACPI_FAILURE (Status))
    394          1.1  christos     {
    395          1.1  christos         return;
    396          1.1  christos     }
    397          1.1  christos 
    398          1.1  christos     /* Release mutex with different parameters */
    399          1.1  christos 
    400          1.1  christos     Status = AcpiReleaseMutex (MutexHandle, NULL);
    401          1.1  christos     ACPI_CHECK_OK (AcpiReleaseMutex, Status);
    402          1.1  christos }
    403          1.1  christos 
    404          1.1  christos 
    405          1.1  christos /******************************************************************************
    406          1.1  christos  *
    407          1.1  christos  * FUNCTION:    AeHardwareInterfaces
    408          1.1  christos  *
    409          1.1  christos  * DESCRIPTION: Call various hardware support interfaces
    410          1.1  christos  *
    411          1.1  christos  *****************************************************************************/
    412          1.1  christos 
    413          1.1  christos static void
    414          1.1  christos AeHardwareInterfaces (
    415          1.1  christos     void)
    416          1.1  christos {
    417          1.1  christos #if (!ACPI_REDUCED_HARDWARE)
    418          1.1  christos 
    419          1.1  christos     ACPI_STATUS             Status;
    420          1.1  christos     UINT32                  Value;
    421          1.1  christos 
    422          1.1  christos 
    423          1.1  christos     /* If Hardware Reduced flag is set, we are all done */
    424          1.1  christos 
    425          1.1  christos     if (AcpiGbl_ReducedHardware)
    426          1.1  christos     {
    427          1.1  christos         return;
    428          1.1  christos     }
    429          1.1  christos 
    430          1.1  christos     Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, 1);
    431          1.1  christos     ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
    432          1.1  christos 
    433          1.1  christos     Status = AcpiWriteBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, 1);
    434          1.1  christos     ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
    435          1.1  christos 
    436          1.1  christos     Status = AcpiWriteBitRegister (ACPI_BITREG_SLEEP_ENABLE, 1);
    437          1.1  christos     ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
    438          1.1  christos 
    439          1.1  christos     Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1);
    440          1.1  christos     ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
    441          1.1  christos 
    442          1.1  christos 
    443          1.1  christos     Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &Value);
    444          1.1  christos     ACPI_CHECK_OK (AcpiReadBitRegister, Status);
    445          1.1  christos 
    446          1.1  christos     Status = AcpiReadBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, &Value);
    447          1.1  christos     ACPI_CHECK_OK (AcpiReadBitRegister, Status);
    448          1.1  christos 
    449          1.1  christos     Status = AcpiReadBitRegister (ACPI_BITREG_SLEEP_ENABLE, &Value);
    450          1.1  christos     ACPI_CHECK_OK (AcpiReadBitRegister, Status);
    451          1.1  christos 
    452          1.1  christos     Status = AcpiReadBitRegister (ACPI_BITREG_ARB_DISABLE, &Value);
    453          1.1  christos     ACPI_CHECK_OK (AcpiReadBitRegister, Status);
    454          1.1  christos 
    455          1.1  christos #endif /* !ACPI_REDUCED_HARDWARE */
    456          1.1  christos }
    457          1.1  christos 
    458          1.1  christos 
    459          1.1  christos /******************************************************************************
    460          1.1  christos  *
    461          1.1  christos  * FUNCTION:    AeTestSleepData
    462          1.1  christos  *
    463          1.1  christos  * DESCRIPTION: Exercise the sleep/wake support (_S0, _S1, etc.)
    464          1.1  christos  *
    465          1.1  christos  *****************************************************************************/
    466          1.1  christos 
    467          1.1  christos static void
    468          1.1  christos AeTestSleepData (
    469          1.1  christos     void)
    470          1.1  christos {
    471          1.1  christos     int                     State;
    472          1.1  christos     UINT8                   TypeA;
    473          1.1  christos     UINT8                   TypeB;
    474          1.1  christos     ACPI_STATUS             Status;
    475          1.1  christos 
    476          1.1  christos 
    477          1.1  christos     /* Attempt to get sleep data for all known sleep states */
    478          1.1  christos 
    479          1.1  christos     for (State = ACPI_STATE_S0; State <= ACPI_S_STATES_MAX; State++)
    480          1.1  christos     {
    481          1.1  christos         Status = AcpiGetSleepTypeData ((UINT8) State, &TypeA, &TypeB);
    482          1.1  christos 
    483          1.1  christos         /* All sleep methods are optional */
    484          1.1  christos 
    485          1.1  christos         if (Status != AE_NOT_FOUND)
    486          1.1  christos         {
    487          1.1  christos             ACPI_CHECK_OK (AcpiGetSleepTypeData, Status);
    488          1.1  christos         }
    489          1.1  christos     }
    490          1.1  christos }
    491      1.1.1.3  christos 
    492      1.1.1.3  christos 
    493      1.1.1.3  christos /******************************************************************************
    494      1.1.1.3  christos  *
    495      1.1.1.3  christos  * FUNCTION:    AeLateTest
    496      1.1.1.3  christos  *
    497      1.1.1.3  christos  * DESCRIPTION: Exercise tests that should be performed before shutdown.
    498      1.1.1.3  christos  *
    499      1.1.1.3  christos  *****************************************************************************/
    500      1.1.1.3  christos 
    501      1.1.1.3  christos void
    502      1.1.1.3  christos AeLateTest (
    503      1.1.1.3  christos     void)
    504      1.1.1.3  christos {
    505      1.1.1.3  christos     AeGlobalAddressRangeCheck();
    506      1.1.1.3  christos }
    507      1.1.1.3  christos 
    508      1.1.1.3  christos 
    509      1.1.1.3  christos /******************************************************************************
    510      1.1.1.3  christos  *
    511      1.1.1.3  christos  * FUNCTION:    AeGlobalAddressRangeCheck
    512      1.1.1.3  christos  *
    513      1.1.1.3  christos  * DESCRIPTION: There have been some issues in the past with adding and
    514      1.1.1.3  christos  *              removing items to the global address list from
    515      1.1.1.3  christos  *              OperationRegions declared in control methods. This test loops
    516      1.1.1.3  christos  *              over the list to ensure that dangling pointers do not exist in
    517      1.1.1.3  christos  *              the global address list.
    518      1.1.1.3  christos  *
    519      1.1.1.3  christos  *****************************************************************************/
    520      1.1.1.3  christos 
    521      1.1.1.3  christos static void
    522      1.1.1.4  christos AeGlobalAddressRangeCheck (
    523      1.1.1.3  christos     void)
    524      1.1.1.3  christos {
    525      1.1.1.3  christos     ACPI_STATUS             Status;
    526      1.1.1.3  christos     ACPI_ADDRESS_RANGE      *Current;
    527      1.1.1.3  christos     ACPI_BUFFER             ReturnBuffer;
    528      1.1.1.3  christos     UINT32                  i;
    529      1.1.1.3  christos 
    530      1.1.1.3  christos 
    531      1.1.1.3  christos     for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++)
    532      1.1.1.3  christos     {
    533      1.1.1.3  christos         Current = AcpiGbl_AddressRangeList[i];
    534      1.1.1.3  christos 
    535      1.1.1.3  christos         while (Current)
    536      1.1.1.3  christos         {
    537      1.1.1.4  christos             ReturnBuffer.Length = ACPI_ALLOCATE_BUFFER;
    538      1.1.1.4  christos 
    539      1.1.1.3  christos             Status = AcpiGetName (Current->RegionNode, ACPI_SINGLE_NAME, &ReturnBuffer);
    540      1.1.1.3  christos             ACPI_CHECK_OK (AcpiGetname, Status);
    541      1.1.1.3  christos 
    542      1.1.1.4  christos             AcpiOsFree (ReturnBuffer.Pointer);
    543      1.1.1.3  christos             Current = Current->Next;
    544      1.1.1.3  christos         }
    545      1.1.1.3  christos     }
    546      1.1.1.3  christos }
    547