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