xref: /netbsd-src/sys/external/bsd/acpica/dist/tools/acpiexec/aeexec.c (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1 /******************************************************************************
2  *
3  * Module Name: aeexec - Support routines for AcpiExec utility
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2011, 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 AfInstallGpeBlock (
57     void);
58 
59 static void
60 AeTestBufferArgument (
61     void);
62 
63 static void
64 AeTestPackageArgument (
65     void);
66 
67 static ACPI_STATUS
68 AeGetDevices (
69     ACPI_HANDLE             ObjHandle,
70     UINT32                  NestingLevel,
71     void                    *Context,
72     void                    **ReturnValue);
73 
74 static ACPI_STATUS
75 ExecuteOSI (
76     char                    *OsiString,
77     UINT32                  ExpectedResult);
78 
79 static void
80 AeHardwareInterfaces (
81     void);
82 
83 static void
84 AeGenericRegisters (
85     void);
86 
87 extern unsigned char Ssdt3Code[];
88 
89 
90 /******************************************************************************
91  *
92  * FUNCTION:    AeSetupConfiguration
93  *
94  * PARAMETERS:  RegionAddr          - Address for an ACPI table to be loaded
95  *                                    dynamically. Test purposes only.
96  *
97  * RETURN:      Status
98  *
99  * DESCRIPTION: Call AML _CFG configuration control method
100  *
101  *****************************************************************************/
102 
103 static ACPI_STATUS
104 AeSetupConfiguration (
105     void                    *RegionAddr)
106 {
107     ACPI_OBJECT_LIST        ArgList;
108     ACPI_OBJECT             Arg[3];
109 
110 
111     /*
112      * Invoke _CFG method if present
113      */
114     ArgList.Count = 1;
115     ArgList.Pointer = Arg;
116 
117     Arg[0].Type = ACPI_TYPE_INTEGER;
118     Arg[0].Integer.Value = ACPI_TO_INTEGER (RegionAddr);
119 
120     (void) AcpiEvaluateObject (NULL, "\\_CFG", &ArgList, NULL);
121     return (AE_OK);
122 }
123 
124 
125 /******************************************************************************
126  *
127  * FUNCTION:    AfInstallGpeBlock
128  *
129  * PARAMETERS:  None
130  *
131  * RETURN:      None
132  *
133  * DESCRIPTION: Test GPE block device initialization. Requires test ASL with
134  *              A \GPE2 device.
135  *
136  *****************************************************************************/
137 
138 static void
139 AfInstallGpeBlock (
140     void)
141 {
142     ACPI_STATUS                 Status;
143     ACPI_HANDLE                 Handle;
144     ACPI_HANDLE                 Handle2 = NULL;
145     ACPI_HANDLE                 Handle3 = NULL;
146     ACPI_GENERIC_ADDRESS        BlockAddress;
147     ACPI_HANDLE                 GpeDevice;
148 
149 
150     Status = AcpiGetHandle (NULL, "\\_GPE", &Handle);
151     if (ACPI_FAILURE (Status))
152     {
153         return;
154     }
155 
156     ACPI_MEMSET (&BlockAddress, 0, sizeof (ACPI_GENERIC_ADDRESS));
157     BlockAddress.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY;
158     BlockAddress.Address = 0x76540000;
159 
160     Status = AcpiGetHandle (NULL, "\\GPE2", &Handle2);
161     if (ACPI_SUCCESS (Status))
162     {
163         Status = AcpiInstallGpeBlock (Handle2, &BlockAddress, 7, 8);
164         AE_CHECK_OK (AcpiInstallGpeBlock, Status);
165 
166         Status = AcpiInstallGpeHandler (Handle2, 8,
167             ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
168         AE_CHECK_OK (AcpiInstallGpeHandler, Status);
169 
170         Status = AcpiEnableGpe (Handle2, 8);
171         AE_CHECK_OK (AcpiEnableGpe, Status);
172 
173         Status = AcpiGetGpeDevice (0x30, &GpeDevice);
174         AE_CHECK_OK (AcpiGetGpeDevice, Status);
175 
176         Status = AcpiGetGpeDevice (0x42, &GpeDevice);
177         AE_CHECK_OK (AcpiGetGpeDevice, Status);
178 
179         Status = AcpiGetGpeDevice (AcpiCurrentGpeCount-1, &GpeDevice);
180         AE_CHECK_OK (AcpiGetGpeDevice, Status);
181 
182         Status = AcpiGetGpeDevice (AcpiCurrentGpeCount, &GpeDevice);
183         AE_CHECK_STATUS (AcpiGetGpeDevice, Status, AE_NOT_EXIST);
184 
185         Status = AcpiRemoveGpeHandler (Handle2, 8, AeGpeHandler);
186         AE_CHECK_OK (AcpiRemoveGpeHandler, Status);
187     }
188 
189     Status = AcpiGetHandle (NULL, "\\GPE3", &Handle3);
190     if (ACPI_SUCCESS (Status))
191     {
192         Status = AcpiInstallGpeBlock (Handle3, &BlockAddress, 8, 11);
193         AE_CHECK_OK (AcpiInstallGpeBlock, Status);
194     }
195 }
196 
197 
198 /* Test using a Buffer object as a method argument */
199 
200 static void
201 AeTestBufferArgument (
202     void)
203 {
204     ACPI_OBJECT_LIST        Params;
205     ACPI_OBJECT             BufArg;
206     UINT8                   Buffer[] = {
207         0,0,0,0,
208         4,0,0,0,
209         1,2,3,4};
210 
211 
212     BufArg.Type = ACPI_TYPE_BUFFER;
213     BufArg.Buffer.Length = 12;
214     BufArg.Buffer.Pointer = Buffer;
215 
216     Params.Count = 1;
217     Params.Pointer = &BufArg;
218 
219     (void) AcpiEvaluateObject (NULL, "\\BUF", &Params, NULL);
220 }
221 
222 
223 static ACPI_OBJECT                 PkgArg;
224 static ACPI_OBJECT                 PkgElements[5];
225 static ACPI_OBJECT                 Pkg2Elements[5];
226 static ACPI_OBJECT_LIST            Params;
227 
228 
229 /*
230  * Test using a Package object as an method argument
231  */
232 static void
233 AeTestPackageArgument (
234     void)
235 {
236 
237     /* Main package */
238 
239     PkgArg.Type = ACPI_TYPE_PACKAGE;
240     PkgArg.Package.Count = 4;
241     PkgArg.Package.Elements = PkgElements;
242 
243     /* Main package elements */
244 
245     PkgElements[0].Type = ACPI_TYPE_INTEGER;
246     PkgElements[0].Integer.Value = 0x22228888;
247 
248     PkgElements[1].Type = ACPI_TYPE_STRING;
249     PkgElements[1].String.Length = sizeof ("Top-level package");
250     PkgElements[1].String.Pointer = "Top-level package";
251 
252     PkgElements[2].Type = ACPI_TYPE_BUFFER;
253     PkgElements[2].Buffer.Length = sizeof ("XXXX");
254     PkgElements[2].Buffer.Pointer = (UINT8 *) "XXXX";
255 
256     PkgElements[3].Type = ACPI_TYPE_PACKAGE;
257     PkgElements[3].Package.Count = 2;
258     PkgElements[3].Package.Elements = Pkg2Elements;
259 
260     /* Sub-package elements */
261 
262     Pkg2Elements[0].Type = ACPI_TYPE_INTEGER;
263     Pkg2Elements[0].Integer.Value = 0xAAAABBBB;
264 
265     Pkg2Elements[1].Type = ACPI_TYPE_STRING;
266     Pkg2Elements[1].String.Length = sizeof ("Nested Package");
267     Pkg2Elements[1].String.Pointer = "Nested Package";
268 
269     /* Parameter object */
270 
271     Params.Count = 1;
272     Params.Pointer = &PkgArg;
273 
274     (void) AcpiEvaluateObject (NULL, "\\_PKG", &Params, NULL);
275 }
276 
277 
278 static ACPI_STATUS
279 AeGetDevices (
280     ACPI_HANDLE                     ObjHandle,
281     UINT32                          NestingLevel,
282     void                            *Context,
283     void                            **ReturnValue)
284 {
285 
286     return (AE_OK);
287 }
288 
289 
290 /******************************************************************************
291  *
292  * FUNCTION:    ExecuteOSI
293  *
294  * PARAMETERS:  OsiString           - String passed to _OSI method
295  *              ExpectedResult      - 0 (FALSE) or 0xFFFFFFFF (TRUE)
296  *
297  * RETURN:      Status
298  *
299  * DESCRIPTION: Execute the internally implemented (in ACPICA) _OSI method.
300  *
301  *****************************************************************************/
302 
303 static ACPI_STATUS
304 ExecuteOSI (
305     char                    *OsiString,
306     UINT32                  ExpectedResult)
307 {
308     ACPI_STATUS             Status;
309     ACPI_OBJECT_LIST        ArgList;
310     ACPI_OBJECT             Arg[1];
311     ACPI_BUFFER             ReturnValue;
312     ACPI_OBJECT             *Obj;
313 
314 
315     /* Setup input argument */
316 
317     ArgList.Count = 1;
318     ArgList.Pointer = Arg;
319 
320     Arg[0].Type = ACPI_TYPE_STRING;
321     Arg[0].String.Pointer = OsiString;
322     Arg[0].String.Length = strlen (Arg[0].String.Pointer);
323 
324     /* Ask ACPICA to allocate space for the return object */
325 
326     ReturnValue.Length = ACPI_ALLOCATE_BUFFER;
327 
328     Status = AcpiEvaluateObject (NULL, "\\_OSI", &ArgList, &ReturnValue);
329 
330     if (ACPI_FAILURE (Status))
331     {
332         AcpiOsPrintf ("Could not execute _OSI method, %s\n",
333             AcpiFormatException (Status));
334         return (Status);
335     }
336 
337     if (ReturnValue.Length < sizeof (ACPI_OBJECT))
338     {
339         AcpiOsPrintf ("Return value from _OSI method too small, %.8X\n",
340             ReturnValue.Length);
341         return (AE_ERROR);
342     }
343 
344     Obj = ReturnValue.Pointer;
345     if (Obj->Type != ACPI_TYPE_INTEGER)
346     {
347         AcpiOsPrintf ("Invalid return type from _OSI method, %.2X\n", Obj->Type);
348         return (AE_ERROR);
349     }
350 
351     if (Obj->Integer.Value != ExpectedResult)
352     {
353         AcpiOsPrintf ("Invalid return value from _OSI, expected %.8X found %.8X\n",
354             ExpectedResult, (UINT32) Obj->Integer.Value);
355         return (AE_ERROR);
356     }
357 
358     /* Reset the OSI data */
359 
360     AcpiGbl_OsiData = 0;
361     return (AE_OK);
362 }
363 
364 
365 /******************************************************************************
366  *
367  * FUNCTION:    AeGenericRegisters
368  *
369  * DESCRIPTION: Call the AcpiRead/Write interfaces.
370  *
371  *****************************************************************************/
372 
373 static ACPI_GENERIC_ADDRESS       GenericRegister;
374 
375 static void
376 AeGenericRegisters (
377     void)
378 {
379     ACPI_STATUS             Status;
380     UINT64                  Value;
381 
382 
383     GenericRegister.Address = 0x1234;
384     GenericRegister.BitWidth = 64;
385     GenericRegister.BitOffset = 0;
386     GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
387 
388     Status = AcpiRead (&Value, &GenericRegister);
389     AE_CHECK_OK (AcpiRead, Status);
390 
391     Status = AcpiWrite (Value, &GenericRegister);
392     AE_CHECK_OK (AcpiWrite, Status);
393 
394     GenericRegister.Address = 0x12345678;
395     GenericRegister.BitOffset = 0;
396     GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY;
397 
398     Status = AcpiRead (&Value, &GenericRegister);
399     AE_CHECK_OK (AcpiRead, Status);
400 
401     Status = AcpiWrite (Value, &GenericRegister);
402     AE_CHECK_OK (AcpiWrite, Status);
403 }
404 
405 
406 /******************************************************************************
407  *
408  * FUNCTION:    AeHardwareInterfaces
409  *
410  * DESCRIPTION: Call various hardware support interfaces
411  *
412  *****************************************************************************/
413 
414 static void
415 AeHardwareInterfaces (
416     void)
417 {
418     ACPI_STATUS             Status;
419     UINT32                  Value;
420 
421 
422     Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, 1);
423     AE_CHECK_OK (AcpiWriteBitRegister, Status);
424 
425     Status = AcpiWriteBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, 1);
426     AE_CHECK_OK (AcpiWriteBitRegister, Status);
427 
428     Status = AcpiWriteBitRegister (ACPI_BITREG_SLEEP_ENABLE, 1);
429     AE_CHECK_OK (AcpiWriteBitRegister, Status);
430 
431     Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1);
432     AE_CHECK_OK (AcpiWriteBitRegister, Status);
433 
434 
435     Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &Value);
436     AE_CHECK_OK (AcpiReadBitRegister, Status);
437 
438     Status = AcpiReadBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, &Value);
439     AE_CHECK_OK (AcpiReadBitRegister, Status);
440 
441     Status = AcpiReadBitRegister (ACPI_BITREG_SLEEP_ENABLE, &Value);
442     AE_CHECK_OK (AcpiReadBitRegister, Status);
443 
444     Status = AcpiReadBitRegister (ACPI_BITREG_ARB_DISABLE, &Value);
445     AE_CHECK_OK (AcpiReadBitRegister, Status);
446 }
447 
448 
449 /******************************************************************************
450  *
451  * FUNCTION:    AeMiscellaneousTests
452  *
453  * DESCRIPTION: Various ACPICA validation tests.
454  *
455  *****************************************************************************/
456 
457 void
458 AeMiscellaneousTests (
459     void)
460 {
461     ACPI_HANDLE             Handle;
462     ACPI_BUFFER             ReturnBuf;
463     char                    Buffer[32];
464     ACPI_VENDOR_UUID        Uuid = {0, {ACPI_INIT_UUID (0,0,0,0,0,0,0,0,0,0,0)}};
465     ACPI_STATUS             Status;
466     UINT32                  LockHandle1;
467     UINT32                  LockHandle2;
468     ACPI_STATISTICS         Stats;
469 
470 
471     AeHardwareInterfaces ();
472     AeGenericRegisters ();
473     AeSetupConfiguration (Ssdt3Code);
474 
475     AeTestBufferArgument();
476     AeTestPackageArgument ();
477 
478 
479     Status = AcpiInstallInterface ("");
480     AE_CHECK_STATUS (AcpiInstallInterface, Status, AE_BAD_PARAMETER);
481 
482     Status = AcpiInstallInterface ("TestString");
483     AE_CHECK_OK (AcpiInstallInterface, Status);
484 
485     Status = AcpiInstallInterface ("TestString");
486     AE_CHECK_STATUS (AcpiInstallInterface, Status, AE_ALREADY_EXISTS);
487 
488     Status = AcpiRemoveInterface ("Windows 2006");
489     AE_CHECK_OK (AcpiRemoveInterface, Status);
490 
491     Status = AcpiRemoveInterface ("TestString");
492     AE_CHECK_OK (AcpiRemoveInterface, Status);
493 
494     Status = AcpiRemoveInterface ("XXXXXX");
495     AE_CHECK_STATUS (AcpiRemoveInterface, Status, AE_NOT_EXIST);
496 
497     Status = AcpiInstallInterface ("AnotherTestString");
498     AE_CHECK_OK (AcpiInstallInterface, Status);
499 
500 
501     Status = ExecuteOSI ("Windows 2001", 0xFFFFFFFF);
502     AE_CHECK_OK (ExecuteOSI, Status);
503 
504     Status = ExecuteOSI ("MichiganTerminalSystem", 0);
505     AE_CHECK_OK (ExecuteOSI, Status);
506 
507 
508     ReturnBuf.Length = 32;
509     ReturnBuf.Pointer = Buffer;
510 
511     Status = AcpiGetName (AcpiGbl_RootNode, ACPI_FULL_PATHNAME, &ReturnBuf);
512     AE_CHECK_OK (AcpiGetName, Status);
513 
514     Status = AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0);
515     AE_CHECK_OK (AcpiEnableEvent, Status);
516 
517     Status = AcpiInstallGlobalEventHandler (AeGlobalEventHandler, NULL);
518     AE_CHECK_OK (AcpiInstallGlobalEventHandler, Status);
519 
520     /*
521      * GPEs: Handlers, enable/disable, etc.
522      */
523     Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
524     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
525 
526     Status = AcpiEnableGpe (NULL, 0);
527     AE_CHECK_OK (AcpiEnableGpe, Status);
528 
529     Status = AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler);
530     AE_CHECK_OK (AcpiRemoveGpeHandler, Status);
531 
532     Status = AcpiInstallGpeHandler (NULL, 0, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
533     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
534 
535     Status = AcpiEnableGpe (NULL, 0);
536     AE_CHECK_OK (AcpiEnableGpe, Status);
537 
538     Status = AcpiSetGpe (NULL, 0, ACPI_GPE_DISABLE);
539     AE_CHECK_OK (AcpiSetGpe, Status);
540 
541     Status = AcpiSetGpe (NULL, 0, ACPI_GPE_ENABLE);
542     AE_CHECK_OK (AcpiSetGpe, Status);
543 
544 
545     Status = AcpiInstallGpeHandler (NULL, 1, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
546     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
547 
548     Status = AcpiEnableGpe (NULL, 1);
549     AE_CHECK_OK (AcpiEnableGpe, Status);
550 
551 
552     Status = AcpiInstallGpeHandler (NULL, 2, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
553     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
554 
555     Status = AcpiEnableGpe (NULL, 2);
556     AE_CHECK_OK (AcpiEnableGpe, Status);
557 
558 
559     Status = AcpiInstallGpeHandler (NULL, 3, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
560     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
561 
562     Status = AcpiInstallGpeHandler (NULL, 4, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
563     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
564 
565     Status = AcpiInstallGpeHandler (NULL, 5, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL);
566     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
567 
568     Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
569     AE_CHECK_OK (AcpiGetHandle, Status);
570 
571     Status = AcpiSetupGpeForWake (Handle, NULL, 5);
572     AE_CHECK_OK (AcpiSetupGpeForWake, Status);
573 
574     Status = AcpiSetGpeWakeMask (NULL, 5, ACPI_GPE_ENABLE);
575     AE_CHECK_OK (AcpiGpeWakeup, Status);
576 
577     Status = AcpiSetupGpeForWake (Handle, NULL, 6);
578     AE_CHECK_OK (AcpiSetupGpeForWake, Status);
579 
580     Status = AcpiSetupGpeForWake (Handle, NULL, 9);
581     AE_CHECK_OK (AcpiSetupGpeForWake, Status);
582 
583     Status = AcpiInstallGpeHandler (NULL, 0x19, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
584     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
585 
586     Status = AcpiEnableGpe (NULL, 0x19);
587     AE_CHECK_OK (AcpiEnableGpe, Status);
588 
589 
590     Status = AcpiInstallGpeHandler (NULL, 0x62, ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL);
591     AE_CHECK_OK (AcpiInstallGpeHandler, Status);
592 
593     Status = AcpiEnableGpe (NULL, 0x62);
594     AE_CHECK_OK (AcpiEnableGpe, Status);
595 
596     Status = AcpiDisableGpe (NULL, 0x62);
597     AE_CHECK_OK (AcpiDisableGpe, Status);
598 
599     AfInstallGpeBlock ();
600 
601     /* Here is where the GPEs are actually "enabled" */
602 
603     Status = AcpiUpdateAllGpes ();
604     AE_CHECK_OK (AcpiUpdateAllGpes, Status);
605 
606     Status = AcpiGetHandle (NULL, "RSRC", &Handle);
607     if (ACPI_SUCCESS (Status))
608     {
609         ReturnBuf.Length = ACPI_ALLOCATE_BUFFER;
610 
611         Status = AcpiGetVendorResource (Handle, "_CRS", &Uuid, &ReturnBuf);
612         if (ACPI_SUCCESS (Status))
613         {
614             AcpiOsFree (ReturnBuf.Pointer);
615         }
616     }
617 
618     /* Test global lock */
619 
620     Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1);
621     AE_CHECK_OK (AcpiAcquireGlobalLock, Status);
622 
623     Status = AcpiAcquireGlobalLock (0x5, &LockHandle2);
624     AE_CHECK_OK (AcpiAcquireGlobalLock, Status);
625 
626     Status = AcpiReleaseGlobalLock (LockHandle1);
627     AE_CHECK_OK (AcpiReleaseGlobalLock, Status);
628 
629     Status = AcpiReleaseGlobalLock (LockHandle2);
630     AE_CHECK_OK (AcpiReleaseGlobalLock, Status);
631 
632     /* Get Devices */
633 
634     Status = AcpiGetDevices (NULL, AeGetDevices, NULL, NULL);
635     AE_CHECK_OK (AcpiGetDevices, Status);
636 
637     Status = AcpiGetStatistics (&Stats);
638     AE_CHECK_OK (AcpiGetStatistics, Status);
639 }
640 
641