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