1 /******************************************************************************
3 * Module Name: aetests - Miscellaneous tests for ACPICA public interfaces
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2019, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "aecommon.h"
154 #define _COMPONENT ACPI_TOOLS
155 ACPI_MODULE_NAME ("aetests")
157 /* Local prototypes */
164 AeHardwareInterfaces (
172 /******************************************************************************
174 * FUNCTION: AeMiscellaneousTests
176 * DESCRIPTION: Various ACPICA validation tests.
178 *****************************************************************************/
181 AeMiscellaneousTests (
184 ACPI_BUFFER ReturnBuf;
187 ACPI_STATISTICS Stats;
190 #if (!ACPI_REDUCED_HARDWARE)
194 ACPI_VENDOR_UUID Uuid = {0, {ACPI_INIT_UUID (0,0,0,0,0,0,0,0,0,0,0)}};
195 #endif /* !ACPI_REDUCED_HARDWARE */
198 Status = AcpiGetHandle (NULL, "\\", &Handle);
199 ACPI_CHECK_OK (AcpiGetHandle, Status);
201 if (AcpiGbl_DoInterfaceTests)
204 * Tests for AcpiLoadTable and AcpiUnloadParentTable
207 /* Attempt unload of DSDT, should fail */
209 Status = AcpiGetHandle (NULL, "\\_SB_", &Handle);
210 ACPI_CHECK_OK (AcpiGetHandle, Status);
212 Status = AcpiUnloadParentTable (Handle);
213 ACPI_CHECK_STATUS (AcpiUnloadParentTable, Status, AE_TYPE);
215 /* Load and unload SSDT4 */
217 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code);
218 ACPI_CHECK_OK (AcpiLoadTable, Status);
220 Status = AcpiGetHandle (NULL, "\\_T96", &Handle);
221 ACPI_CHECK_OK (AcpiGetHandle, Status);
223 Status = AcpiUnloadParentTable (Handle);
224 ACPI_CHECK_OK (AcpiUnloadParentTable, Status);
228 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code);
229 ACPI_CHECK_OK (AcpiLoadTable, Status);
231 /* Unload and re-load SSDT2 (SSDT2 is in the XSDT) */
233 Status = AcpiGetHandle (NULL, "\\_T99", &Handle);
234 ACPI_CHECK_OK (AcpiGetHandle, Status);
236 Status = AcpiUnloadParentTable (Handle);
237 ACPI_CHECK_OK (AcpiUnloadParentTable, Status);
239 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt2Code);
240 ACPI_CHECK_OK (AcpiLoadTable, Status);
242 /* Load OEM9 table (causes table override) */
244 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt3Code);
245 ACPI_CHECK_OK (AcpiLoadTable, Status);
248 AeHardwareInterfaces ();
249 AeGenericRegisters ();
250 AeSetupConfiguration (Ssdt3Code);
252 AeTestBufferArgument();
253 AeTestPackageArgument ();
254 AeMutexInterfaces ();
257 /* Test _OSI install/remove */
259 Status = AcpiInstallInterface ("");
260 ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_BAD_PARAMETER);
262 Status = AcpiInstallInterface ("TestString");
263 ACPI_CHECK_OK (AcpiInstallInterface, Status);
265 Status = AcpiInstallInterface ("TestString");
266 ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_ALREADY_EXISTS);
268 Status = AcpiRemoveInterface ("Windows 2006");
269 ACPI_CHECK_OK (AcpiRemoveInterface, Status);
271 Status = AcpiRemoveInterface ("TestString");
272 ACPI_CHECK_OK (AcpiRemoveInterface, Status);
274 Status = AcpiRemoveInterface ("XXXXXX");
275 ACPI_CHECK_STATUS (AcpiRemoveInterface, Status, AE_NOT_EXIST);
277 Status = AcpiInstallInterface ("AnotherTestString");
278 ACPI_CHECK_OK (AcpiInstallInterface, Status);
280 /* Test _OSI execution */
282 Status = ExecuteOSI ("Extended Address Space Descriptor", ACPI_UINT64_MAX);
283 ACPI_CHECK_OK (ExecuteOSI, Status);
285 Status = ExecuteOSI ("Windows 2001", ACPI_UINT64_MAX);
286 ACPI_CHECK_OK (ExecuteOSI, Status);
288 Status = ExecuteOSI ("MichiganTerminalSystem", 0);
289 ACPI_CHECK_OK (ExecuteOSI, Status);
292 ReturnBuf.Length = 32;
293 ReturnBuf.Pointer = Buffer;
295 Status = AcpiGetName (ACPI_ROOT_OBJECT,
296 ACPI_FULL_PATHNAME_NO_TRAILING, &ReturnBuf);
297 ACPI_CHECK_OK (AcpiGetName, Status);
301 Status = AcpiGetDevices (NULL, AeGetDevices, NULL, NULL);
302 ACPI_CHECK_OK (AcpiGetDevices, Status);
304 Status = AcpiGetStatistics (&Stats);
305 ACPI_CHECK_OK (AcpiGetStatistics, Status);
308 #if (!ACPI_REDUCED_HARDWARE)
310 Status = AcpiInstallGlobalEventHandler (AeGlobalEventHandler, NULL);
311 ACPI_CHECK_OK (AcpiInstallGlobalEventHandler, Status);
313 /* If Hardware Reduced flag is set, we are all done */
315 if (AcpiGbl_ReducedHardware)
320 Status = AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0);
321 ACPI_CHECK_OK (AcpiEnableEvent, Status);
324 * GPEs: Handlers, enable/disable, etc.
326 Status = AcpiInstallGpeHandler (NULL, 0,
327 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
328 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
330 Status = AcpiEnableGpe (NULL, 0);
331 ACPI_CHECK_OK (AcpiEnableGpe, Status);
333 Status = AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler);
334 ACPI_CHECK_OK (AcpiRemoveGpeHandler, Status);
336 Status = AcpiInstallGpeHandler (NULL, 0,
337 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
338 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
340 Status = AcpiEnableGpe (NULL, 0);
341 ACPI_CHECK_OK (AcpiEnableGpe, Status);
343 Status = AcpiSetGpe (NULL, 0, ACPI_GPE_DISABLE);
344 ACPI_CHECK_OK (AcpiSetGpe, Status);
346 Status = AcpiSetGpe (NULL, 0, ACPI_GPE_ENABLE);
347 ACPI_CHECK_OK (AcpiSetGpe, Status);
350 Status = AcpiInstallGpeHandler (NULL, 1,
351 ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
352 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
354 Status = AcpiEnableGpe (NULL, 1);
355 ACPI_CHECK_OK (AcpiEnableGpe, Status);
358 Status = AcpiInstallGpeHandler (NULL, 2,
359 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
360 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
362 Status = AcpiEnableGpe (NULL, 2);
363 ACPI_CHECK_OK (AcpiEnableGpe, Status);
366 Status = AcpiInstallGpeHandler (NULL, 3,
367 ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
368 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
370 Status = AcpiInstallGpeHandler (NULL, 4,
371 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
372 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
374 Status = AcpiInstallGpeHandler (NULL, 5,
375 ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
376 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
378 Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
379 ACPI_CHECK_OK (AcpiGetHandle, Status);
381 Status = AcpiSetupGpeForWake (Handle, NULL, 5);
382 ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
384 Status = AcpiSetGpeWakeMask (NULL, 5, ACPI_GPE_ENABLE);
385 ACPI_CHECK_OK (AcpiSetGpeWakeMask, Status);
387 Status = AcpiSetupGpeForWake (Handle, NULL, 6);
388 ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
390 Status = AcpiSetupGpeForWake (ACPI_ROOT_OBJECT, NULL, 6);
391 ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
393 Status = AcpiSetupGpeForWake (Handle, NULL, 9);
394 ACPI_CHECK_OK (AcpiSetupGpeForWake, Status);
396 Status = AcpiInstallGpeHandler (NULL, 0x19,
397 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
398 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
400 Status = AcpiEnableGpe (NULL, 0x19);
401 ACPI_CHECK_OK (AcpiEnableGpe, Status);
406 Status = AcpiInstallGpeHandler (NULL, 101,
407 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
408 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status);
410 Status = AcpiEnableGpe (NULL, 101);
411 ACPI_CHECK_OK (AcpiEnableGpe, Status);
413 Status = AcpiDisableGpe (NULL, 101);
414 ACPI_CHECK_OK (AcpiDisableGpe, Status);
416 AfInstallGpeBlock ();
418 /* Here is where the GPEs are actually "enabled" */
420 Status = AcpiUpdateAllGpes ();
421 ACPI_CHECK_OK (AcpiUpdateAllGpes, Status);
423 Status = AcpiGetHandle (NULL, "RSRC", &Handle);
424 if (ACPI_SUCCESS (Status))
426 ReturnBuf.Length = ACPI_ALLOCATE_BUFFER;
428 Status = AcpiGetVendorResource (Handle, "_CRS", &Uuid, &ReturnBuf);
429 if (ACPI_SUCCESS (Status))
431 AcpiOsFree (ReturnBuf.Pointer);
435 /* Test global lock */
437 Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1);
438 ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status);
440 Status = AcpiAcquireGlobalLock (0x5, &LockHandle2);
441 ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status);
443 Status = AcpiReleaseGlobalLock (LockHandle1);
444 ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status);
446 Status = AcpiReleaseGlobalLock (LockHandle2);
447 ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status);
449 /* Test timer interfaces */
451 Status = AcpiGetTimerResolution (&Temp);
452 ACPI_CHECK_OK (AcpiGetTimerResolution, Status);
454 Status = AcpiGetTimer (&Temp);
455 ACPI_CHECK_OK (AcpiGetTimer, Status);
457 Status = AcpiGetTimerDuration (0x1000, 0x2000, &Temp);
458 ACPI_CHECK_OK (AcpiGetTimerDuration, Status);
461 #endif /* !ACPI_REDUCED_HARDWARE */
465 /******************************************************************************
467 * FUNCTION: AeMutexInterfaces
469 * DESCRIPTION: Exercise the AML mutex access interfaces
471 *****************************************************************************/
478 ACPI_HANDLE MutexHandle;
481 /* Get a handle to an AML mutex */
483 Status = AcpiGetHandle (NULL, "\\MTX1", &MutexHandle);
484 if (Status == AE_NOT_FOUND)
489 ACPI_CHECK_OK (AcpiGetHandle, Status);
490 if (ACPI_FAILURE (Status))
495 /* Acquire the mutex */
497 Status = AcpiAcquireMutex (NULL, "\\MTX1", 0xFFFF);
498 ACPI_CHECK_OK (AcpiAcquireMutex, Status);
499 if (ACPI_FAILURE (Status))
504 /* Release mutex with different parameters */
506 Status = AcpiReleaseMutex (MutexHandle, NULL);
507 ACPI_CHECK_OK (AcpiReleaseMutex, Status);
511 /******************************************************************************
513 * FUNCTION: AeHardwareInterfaces
515 * DESCRIPTION: Call various hardware support interfaces
517 *****************************************************************************/
520 AeHardwareInterfaces (
523 #if (!ACPI_REDUCED_HARDWARE)
529 /* If Hardware Reduced flag is set, we are all done */
531 if (AcpiGbl_ReducedHardware)
536 Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, 1);
537 ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
539 Status = AcpiWriteBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, 1);
540 ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
542 Status = AcpiWriteBitRegister (ACPI_BITREG_SLEEP_ENABLE, 1);
543 ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
545 Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1);
546 ACPI_CHECK_OK (AcpiWriteBitRegister, Status);
549 Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &Value);
550 ACPI_CHECK_OK (AcpiReadBitRegister, Status);
552 Status = AcpiReadBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, &Value);
553 ACPI_CHECK_OK (AcpiReadBitRegister, Status);
555 Status = AcpiReadBitRegister (ACPI_BITREG_SLEEP_ENABLE, &Value);
556 ACPI_CHECK_OK (AcpiReadBitRegister, Status);
558 Status = AcpiReadBitRegister (ACPI_BITREG_ARB_DISABLE, &Value);
559 ACPI_CHECK_OK (AcpiReadBitRegister, Status);
561 #endif /* !ACPI_REDUCED_HARDWARE */
565 /******************************************************************************
567 * FUNCTION: AeTestSleepData
569 * DESCRIPTION: Exercise the sleep/wake support (_S0, _S1, etc.)
571 *****************************************************************************/
583 /* Attempt to get sleep data for all known sleep states */
585 for (State = ACPI_STATE_S0; State <= ACPI_S_STATES_MAX; State++)
587 Status = AcpiGetSleepTypeData ((UINT8) State, &TypeA, &TypeB);
589 /* All sleep methods are optional */
591 if (Status != AE_NOT_FOUND)
593 ACPI_CHECK_OK (AcpiGetSleepTypeData, Status);