1 /******************************************************************************
3 * Module Name: aeexec - Argument testing for control method execution.
4 * Also some other miscellaneous tests.
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************
117 * Alternatively, you may choose to be licensed under the terms of the
120 * Redistribution and use in source and binary forms, with or without
121 * modification, are permitted provided that the following conditions
123 * 1. Redistributions of source code must retain the above copyright
124 * notice, this list of conditions, and the following disclaimer,
125 * without modification.
126 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
127 * substantially similar to the "NO WARRANTY" disclaimer below
128 * ("Disclaimer") and any redistribution must be conditioned upon
129 * including a substantially similar Disclaimer requirement for further
130 * binary redistribution.
131 * 3. Neither the names of the above-listed copyright holders nor the names
132 * of any contributors may be used to endorse or promote products derived
133 * from this software without specific prior written permission.
135 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
147 * Alternatively, you may choose to be licensed under the terms of the
148 * GNU General Public License ("GPL") version 2 as published by the Free
149 * Software Foundation.
151 *****************************************************************************/
153 #include "aecommon.h"
155 #define _COMPONENT ACPI_TOOLS
156 ACPI_MODULE_NAME ("aeexec")
159 /******************************************************************************
161 * FUNCTION: AeSetupConfiguration
163 * PARAMETERS: RegionAddr - Address for an ACPI table to be loaded
164 * dynamically. Test purposes only.
168 * DESCRIPTION: Call AML _CFG configuration control method
170 *****************************************************************************/
173 AeSetupConfiguration (
176 ACPI_OBJECT_LIST ArgList
;
181 * Invoke _CFG method if present
184 ArgList
.Pointer
= Arg
;
186 Arg
[0].Type
= ACPI_TYPE_INTEGER
;
187 Arg
[0].Integer
.Value
= ACPI_TO_INTEGER (RegionAddr
);
189 (void) AcpiEvaluateObject (NULL
, "\\_CFG", &ArgList
, NULL
);
194 #if (!ACPI_REDUCED_HARDWARE)
195 /******************************************************************************
197 * FUNCTION: AfInstallGpeBlock
203 * DESCRIPTION: Test GPE block device initialization. Requires test ASL with
206 *****************************************************************************/
214 ACPI_GENERIC_ADDRESS BlockAddress
;
215 ACPI_HANDLE GpeDevice
;
216 ACPI_OBJECT_TYPE Type
;
219 /* _GPE should always exist */
221 Status
= AcpiGetHandle (NULL
, "\\_GPE", &Handle
);
222 ACPI_CHECK_OK (AcpiGetHandle
, Status
);
223 if (ACPI_FAILURE (Status
))
228 memset (&BlockAddress
, 0, sizeof (ACPI_GENERIC_ADDRESS
));
229 BlockAddress
.SpaceId
= ACPI_ADR_SPACE_SYSTEM_MEMORY
;
230 BlockAddress
.Address
= 0x76540000;
232 /* Attempt to install a GPE block on GPE2 (if present) */
234 Status
= AcpiGetHandle (NULL
, "\\GPE2", &Handle
);
235 if (ACPI_SUCCESS (Status
))
237 Status
= AcpiGetType (Handle
, &Type
);
238 if (ACPI_FAILURE (Status
) ||
239 (Type
!= ACPI_TYPE_DEVICE
))
244 Status
= AcpiInstallGpeBlock (Handle
, &BlockAddress
, 7, 8);
245 ACPI_CHECK_OK (AcpiInstallGpeBlock
, Status
);
247 Status
= AcpiInstallGpeHandler (Handle
, 8,
248 ACPI_GPE_LEVEL_TRIGGERED
, AeGpeHandler
, NULL
);
249 ACPI_CHECK_OK (AcpiInstallGpeHandler
, Status
);
251 Status
= AcpiEnableGpe (Handle
, 8);
252 ACPI_CHECK_OK (AcpiEnableGpe
, Status
);
254 Status
= AcpiGetGpeDevice (0x30, &GpeDevice
);
255 ACPI_CHECK_OK (AcpiGetGpeDevice
, Status
);
257 Status
= AcpiGetGpeDevice (0x42, &GpeDevice
);
258 ACPI_CHECK_OK (AcpiGetGpeDevice
, Status
);
260 Status
= AcpiGetGpeDevice (AcpiCurrentGpeCount
-1, &GpeDevice
);
261 ACPI_CHECK_OK (AcpiGetGpeDevice
, Status
);
263 Status
= AcpiGetGpeDevice (AcpiCurrentGpeCount
, &GpeDevice
);
264 ACPI_CHECK_STATUS (AcpiGetGpeDevice
, Status
, AE_NOT_EXIST
);
266 Status
= AcpiRemoveGpeHandler (Handle
, 8, AeGpeHandler
);
267 ACPI_CHECK_OK (AcpiRemoveGpeHandler
, Status
);
270 /* Attempt to install a GPE block on GPE3 (if present) */
272 Status
= AcpiGetHandle (NULL
, "\\GPE3", &Handle
);
273 if (ACPI_SUCCESS (Status
))
275 Status
= AcpiGetType (Handle
, &Type
);
276 if (ACPI_FAILURE (Status
) ||
277 (Type
!= ACPI_TYPE_DEVICE
))
282 Status
= AcpiInstallGpeBlock (Handle
, &BlockAddress
, 8, 11);
283 ACPI_CHECK_OK (AcpiInstallGpeBlock
, Status
);
286 #endif /* !ACPI_REDUCED_HARDWARE */
289 /******************************************************************************
291 * FUNCTION: AeTestBufferArgument
293 * DESCRIPTION: Test using a Buffer object as a method argument
295 *****************************************************************************/
298 AeTestBufferArgument (
301 ACPI_OBJECT_LIST Params
;
311 BufArg
.Type
= ACPI_TYPE_BUFFER
;
312 BufArg
.Buffer
.Length
= 12;
313 BufArg
.Buffer
.Pointer
= Buffer
;
316 Params
.Pointer
= &BufArg
;
318 (void) AcpiEvaluateObject (NULL
, "\\BUF", &Params
, NULL
);
322 static ACPI_OBJECT PkgArg
;
323 static ACPI_OBJECT PkgElements
[5];
324 static ACPI_OBJECT Pkg2Elements
[5];
325 static ACPI_OBJECT_LIST Params
;
327 /******************************************************************************
329 * FUNCTION: AeTestPackageArgument
331 * DESCRIPTION: Test using a Package object as a method argument
333 *****************************************************************************/
336 AeTestPackageArgument (
342 PkgArg
.Type
= ACPI_TYPE_PACKAGE
;
343 PkgArg
.Package
.Count
= 4;
344 PkgArg
.Package
.Elements
= PkgElements
;
346 /* Main package elements */
348 PkgElements
[0].Type
= ACPI_TYPE_INTEGER
;
349 PkgElements
[0].Integer
.Value
= 0x22228888;
351 PkgElements
[1].Type
= ACPI_TYPE_STRING
;
352 PkgElements
[1].String
.Length
= sizeof ("Top-level package");
353 PkgElements
[1].String
.Pointer
= "Top-level package";
355 PkgElements
[2].Type
= ACPI_TYPE_BUFFER
;
356 PkgElements
[2].Buffer
.Length
= sizeof ("XXXX");
357 PkgElements
[2].Buffer
.Pointer
= (UINT8
*) "XXXX";
359 PkgElements
[3].Type
= ACPI_TYPE_PACKAGE
;
360 PkgElements
[3].Package
.Count
= 2;
361 PkgElements
[3].Package
.Elements
= Pkg2Elements
;
363 /* Subpackage elements */
365 Pkg2Elements
[0].Type
= ACPI_TYPE_INTEGER
;
366 Pkg2Elements
[0].Integer
.Value
= 0xAAAABBBB;
368 Pkg2Elements
[1].Type
= ACPI_TYPE_STRING
;
369 Pkg2Elements
[1].String
.Length
= sizeof ("Nested Package");
370 Pkg2Elements
[1].String
.Pointer
= "Nested Package";
372 /* Parameter object */
375 Params
.Pointer
= &PkgArg
;
377 (void) AcpiEvaluateObject (NULL
, "\\_PKG", &Params
, NULL
);
381 /******************************************************************************
383 * FUNCTION: AeGetDevices
385 * DESCRIPTION: Stubbed at this time.
387 *****************************************************************************/
391 ACPI_HANDLE ObjHandle
,
401 /******************************************************************************
403 * FUNCTION: ExecuteOSI
405 * PARAMETERS: OsiString - String passed to _OSI method
406 * ExpectedResult - 0 (FALSE) or ACPI_UINT64_MAX (TRUE)
410 * DESCRIPTION: Execute the internally implemented (in ACPICA) _OSI method.
412 *****************************************************************************/
417 UINT64 ExpectedResult
)
420 ACPI_OBJECT_LIST ArgList
;
422 ACPI_BUFFER ReturnValue
;
426 /* Setup input argument */
429 ArgList
.Pointer
= Arg
;
431 Arg
[0].Type
= ACPI_TYPE_STRING
;
432 Arg
[0].String
.Pointer
= OsiString
;
433 Arg
[0].String
.Length
= strlen (Arg
[0].String
.Pointer
);
435 /* Ask ACPICA to allocate space for the return object */
437 ReturnValue
.Length
= ACPI_ALLOCATE_BUFFER
;
439 Status
= AcpiEvaluateObject (NULL
, "\\_OSI", &ArgList
, &ReturnValue
);
441 if (ACPI_FAILURE (Status
))
444 "Could not execute _OSI method, %s\n",
445 AcpiFormatException (Status
));
451 if (ReturnValue
.Length
< sizeof (ACPI_OBJECT
))
454 "Return value from _OSI method too small, %.8X\n",
459 Obj
= ReturnValue
.Pointer
;
460 if (Obj
->Type
!= ACPI_TYPE_INTEGER
)
463 "Invalid return type from _OSI method, %.2X\n", Obj
->Type
);
467 if (Obj
->Integer
.Value
!= ExpectedResult
)
470 "Invalid return value from _OSI, expected %8.8X%8.8X found %8.8X%8.8X\n",
471 ACPI_FORMAT_UINT64 (ExpectedResult
),
472 ACPI_FORMAT_UINT64 (Obj
->Integer
.Value
));
478 /* Reset the OSI data */
484 /* Free a buffer created via ACPI_ALLOCATE_BUFFER */
486 AcpiOsFree (ReturnValue
.Pointer
);
491 /******************************************************************************
493 * FUNCTION: AeGenericRegisters
495 * DESCRIPTION: Call the AcpiRead/Write interfaces.
497 *****************************************************************************/
499 static ACPI_GENERIC_ADDRESS GenericRegister
;
509 GenericRegister
.Address
= 0x1234;
510 GenericRegister
.BitWidth
= 64;
511 GenericRegister
.BitOffset
= 0;
512 GenericRegister
.SpaceId
= ACPI_ADR_SPACE_SYSTEM_IO
;
514 Status
= AcpiRead (&Value
, &GenericRegister
);
515 ACPI_CHECK_OK (AcpiRead
, Status
);
517 Status
= AcpiWrite (Value
, &GenericRegister
);
518 ACPI_CHECK_OK (AcpiWrite
, Status
);
520 GenericRegister
.Address
= 0x12345678;
521 GenericRegister
.BitOffset
= 0;
522 GenericRegister
.SpaceId
= ACPI_ADR_SPACE_SYSTEM_MEMORY
;
524 Status
= AcpiRead (&Value
, &GenericRegister
);
525 ACPI_CHECK_OK (AcpiRead
, Status
);
527 Status
= AcpiWrite (Value
, &GenericRegister
);
528 ACPI_CHECK_OK (AcpiWrite
, Status
);