xref: /freebsd/sys/contrib/dev/acpica/components/utilities/utxface.c (revision 94e3ee44c3581ff37c5e01b5ffe5eb16d30079a7)
1 /******************************************************************************
2  *
3  * Module Name: utxface - External interfaces for "global" ACPI functions
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2012, 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 
45 #define __UTXFACE_C__
46 
47 #include <contrib/dev/acpica/include/acpi.h>
48 #include <contrib/dev/acpica/include/accommon.h>
49 #include <contrib/dev/acpica/include/acevents.h>
50 #include <contrib/dev/acpica/include/acnamesp.h>
51 #include <contrib/dev/acpica/include/acdebug.h>
52 #include <contrib/dev/acpica/include/actables.h>
53 
54 #define _COMPONENT          ACPI_UTILITIES
55         ACPI_MODULE_NAME    ("utxface")
56 
57 
58 #ifndef ACPI_ASL_COMPILER
59 /*******************************************************************************
60  *
61  * FUNCTION:    AcpiInitializeSubsystem
62  *
63  * PARAMETERS:  None
64  *
65  * RETURN:      Status
66  *
67  * DESCRIPTION: Initializes all global variables.  This is the first function
68  *              called, so any early initialization belongs here.
69  *
70  ******************************************************************************/
71 
72 ACPI_STATUS
73 AcpiInitializeSubsystem (
74     void)
75 {
76     ACPI_STATUS             Status;
77 
78 
79     ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
80 
81 
82     AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
83     ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
84 
85     /* Initialize the OS-Dependent layer */
86 
87     Status = AcpiOsInitialize ();
88     if (ACPI_FAILURE (Status))
89     {
90         ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
91         return_ACPI_STATUS (Status);
92     }
93 
94     /* Initialize all globals used by the subsystem */
95 
96     Status = AcpiUtInitGlobals ();
97     if (ACPI_FAILURE (Status))
98     {
99         ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
100         return_ACPI_STATUS (Status);
101     }
102 
103     /* Create the default mutex objects */
104 
105     Status = AcpiUtMutexInitialize ();
106     if (ACPI_FAILURE (Status))
107     {
108         ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
109         return_ACPI_STATUS (Status);
110     }
111 
112     /*
113      * Initialize the namespace manager and
114      * the root of the namespace tree
115      */
116     Status = AcpiNsRootInitialize ();
117     if (ACPI_FAILURE (Status))
118     {
119         ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
120         return_ACPI_STATUS (Status);
121     }
122 
123     /* Initialize the global OSI interfaces list with the static names */
124 
125     Status = AcpiUtInitializeInterfaces ();
126     if (ACPI_FAILURE (Status))
127     {
128         ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
129         return_ACPI_STATUS (Status);
130     }
131 
132     /* If configured, initialize the AML debugger */
133 
134     ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ());
135     return_ACPI_STATUS (Status);
136 }
137 
138 ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem)
139 
140 
141 /*******************************************************************************
142  *
143  * FUNCTION:    AcpiEnableSubsystem
144  *
145  * PARAMETERS:  Flags           - Init/enable Options
146  *
147  * RETURN:      Status
148  *
149  * DESCRIPTION: Completes the subsystem initialization including hardware.
150  *              Puts system into ACPI mode if it isn't already.
151  *
152  ******************************************************************************/
153 
154 ACPI_STATUS
155 AcpiEnableSubsystem (
156     UINT32                  Flags)
157 {
158     ACPI_STATUS             Status = AE_OK;
159 
160 
161     ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
162 
163 
164 #if (!ACPI_REDUCED_HARDWARE)
165 
166     /* Enable ACPI mode */
167 
168     if (!(Flags & ACPI_NO_ACPI_ENABLE))
169     {
170         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
171 
172         AcpiGbl_OriginalMode = AcpiHwGetMode();
173 
174         Status = AcpiEnable ();
175         if (ACPI_FAILURE (Status))
176         {
177             ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
178             return_ACPI_STATUS (Status);
179         }
180     }
181 
182     /*
183      * Obtain a permanent mapping for the FACS. This is required for the
184      * Global Lock and the Firmware Waking Vector
185      */
186     Status = AcpiTbInitializeFacs ();
187     if (ACPI_FAILURE (Status))
188     {
189         ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
190         return_ACPI_STATUS (Status);
191     }
192 
193 #endif /* !ACPI_REDUCED_HARDWARE */
194 
195     /*
196      * Install the default OpRegion handlers.  These are installed unless
197      * other handlers have already been installed via the
198      * InstallAddressSpaceHandler interface.
199      */
200     if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
201     {
202         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
203             "[Init] Installing default address space handlers\n"));
204 
205         Status = AcpiEvInstallRegionHandlers ();
206         if (ACPI_FAILURE (Status))
207         {
208             return_ACPI_STATUS (Status);
209         }
210     }
211 
212 #if (!ACPI_REDUCED_HARDWARE)
213     /*
214      * Initialize ACPI Event handling (Fixed and General Purpose)
215      *
216      * Note1: We must have the hardware and events initialized before we can
217      * execute any control methods safely. Any control method can require
218      * ACPI hardware support, so the hardware must be fully initialized before
219      * any method execution!
220      *
221      * Note2: Fixed events are initialized and enabled here. GPEs are
222      * initialized, but cannot be enabled until after the hardware is
223      * completely initialized (SCI and GlobalLock activated) and the various
224      * initialization control methods are run (_REG, _STA, _INI) on the
225      * entire namespace.
226      */
227     if (!(Flags & ACPI_NO_EVENT_INIT))
228     {
229         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
230             "[Init] Initializing ACPI events\n"));
231 
232         Status = AcpiEvInitializeEvents ();
233         if (ACPI_FAILURE (Status))
234         {
235             return_ACPI_STATUS (Status);
236         }
237     }
238 
239     /*
240      * Install the SCI handler and Global Lock handler. This completes the
241      * hardware initialization.
242      */
243     if (!(Flags & ACPI_NO_HANDLER_INIT))
244     {
245         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
246             "[Init] Installing SCI/GL handlers\n"));
247 
248         Status = AcpiEvInstallXruptHandlers ();
249         if (ACPI_FAILURE (Status))
250         {
251             return_ACPI_STATUS (Status);
252         }
253     }
254 
255 #endif /* !ACPI_REDUCED_HARDWARE */
256 
257     return_ACPI_STATUS (Status);
258 }
259 
260 ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem)
261 
262 
263 /*******************************************************************************
264  *
265  * FUNCTION:    AcpiInitializeObjects
266  *
267  * PARAMETERS:  Flags           - Init/enable Options
268  *
269  * RETURN:      Status
270  *
271  * DESCRIPTION: Completes namespace initialization by initializing device
272  *              objects and executing AML code for Regions, buffers, etc.
273  *
274  ******************************************************************************/
275 
276 ACPI_STATUS
277 AcpiInitializeObjects (
278     UINT32                  Flags)
279 {
280     ACPI_STATUS             Status = AE_OK;
281 
282 
283     ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
284 
285 
286     /*
287      * Run all _REG methods
288      *
289      * Note: Any objects accessed by the _REG methods will be automatically
290      * initialized, even if they contain executable AML (see the call to
291      * AcpiNsInitializeObjects below).
292      */
293     if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
294     {
295         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
296             "[Init] Executing _REG OpRegion methods\n"));
297 
298         Status = AcpiEvInitializeOpRegions ();
299         if (ACPI_FAILURE (Status))
300         {
301             return_ACPI_STATUS (Status);
302         }
303     }
304 
305     /*
306      * Execute any module-level code that was detected during the table load
307      * phase. Although illegal since ACPI 2.0, there are many machines that
308      * contain this type of code. Each block of detected executable AML code
309      * outside of any control method is wrapped with a temporary control
310      * method object and placed on a global list. The methods on this list
311      * are executed below.
312      */
313     AcpiNsExecModuleCodeList ();
314 
315     /*
316      * Initialize the objects that remain uninitialized. This runs the
317      * executable AML that may be part of the declaration of these objects:
318      * OperationRegions, BufferFields, Buffers, and Packages.
319      */
320     if (!(Flags & ACPI_NO_OBJECT_INIT))
321     {
322         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
323             "[Init] Completing Initialization of ACPI Objects\n"));
324 
325         Status = AcpiNsInitializeObjects ();
326         if (ACPI_FAILURE (Status))
327         {
328             return_ACPI_STATUS (Status);
329         }
330     }
331 
332     /*
333      * Initialize all device objects in the namespace. This runs the device
334      * _STA and _INI methods.
335      */
336     if (!(Flags & ACPI_NO_DEVICE_INIT))
337     {
338         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
339             "[Init] Initializing ACPI Devices\n"));
340 
341         Status = AcpiNsInitializeDevices ();
342         if (ACPI_FAILURE (Status))
343         {
344             return_ACPI_STATUS (Status);
345         }
346     }
347 
348     /*
349      * Empty the caches (delete the cached objects) on the assumption that
350      * the table load filled them up more than they will be at runtime --
351      * thus wasting non-paged memory.
352      */
353     Status = AcpiPurgeCachedObjects ();
354 
355     AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
356     return_ACPI_STATUS (Status);
357 }
358 
359 ACPI_EXPORT_SYMBOL (AcpiInitializeObjects)
360 
361 
362 #endif
363 
364 /*******************************************************************************
365  *
366  * FUNCTION:    AcpiTerminate
367  *
368  * PARAMETERS:  None
369  *
370  * RETURN:      Status
371  *
372  * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
373  *
374  ******************************************************************************/
375 
376 ACPI_STATUS
377 AcpiTerminate (
378     void)
379 {
380     ACPI_STATUS         Status;
381 
382 
383     ACPI_FUNCTION_TRACE (AcpiTerminate);
384 
385 
386     /* Just exit if subsystem is already shutdown */
387 
388     if (AcpiGbl_Shutdown)
389     {
390         ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated"));
391         return_ACPI_STATUS (AE_OK);
392     }
393 
394     /* Subsystem appears active, go ahead and shut it down */
395 
396     AcpiGbl_Shutdown = TRUE;
397     AcpiGbl_StartupFlags = 0;
398     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
399 
400     /* Terminate the AML Debugger if present */
401 
402     ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE);
403 
404     /* Shutdown and free all resources */
405 
406     AcpiUtSubsystemShutdown ();
407 
408     /* Free the mutex objects */
409 
410     AcpiUtMutexTerminate ();
411 
412 
413 #ifdef ACPI_DEBUGGER
414 
415     /* Shut down the debugger */
416 
417     AcpiDbTerminate ();
418 #endif
419 
420     /* Now we can shutdown the OS-dependent layer */
421 
422     Status = AcpiOsTerminate ();
423     return_ACPI_STATUS (Status);
424 }
425 
426 ACPI_EXPORT_SYMBOL (AcpiTerminate)
427 
428 
429 #ifndef ACPI_ASL_COMPILER
430 /*******************************************************************************
431  *
432  * FUNCTION:    AcpiSubsystemStatus
433  *
434  * PARAMETERS:  None
435  *
436  * RETURN:      Status of the ACPI subsystem
437  *
438  * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
439  *              before making any other calls, to ensure the subsystem
440  *              initialized successfully.
441  *
442  ******************************************************************************/
443 
444 ACPI_STATUS
445 AcpiSubsystemStatus (
446     void)
447 {
448 
449     if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK)
450     {
451         return (AE_OK);
452     }
453     else
454     {
455         return (AE_ERROR);
456     }
457 }
458 
459 ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus)
460 
461 
462 /*******************************************************************************
463  *
464  * FUNCTION:    AcpiGetSystemInfo
465  *
466  * PARAMETERS:  OutBuffer       - A buffer to receive the resources for the
467  *                                device
468  *
469  * RETURN:      Status          - the status of the call
470  *
471  * DESCRIPTION: This function is called to get information about the current
472  *              state of the ACPI subsystem.  It will return system information
473  *              in the OutBuffer.
474  *
475  *              If the function fails an appropriate status will be returned
476  *              and the value of OutBuffer is undefined.
477  *
478  ******************************************************************************/
479 
480 ACPI_STATUS
481 AcpiGetSystemInfo (
482     ACPI_BUFFER             *OutBuffer)
483 {
484     ACPI_SYSTEM_INFO        *InfoPtr;
485     ACPI_STATUS             Status;
486 
487 
488     ACPI_FUNCTION_TRACE (AcpiGetSystemInfo);
489 
490 
491     /* Parameter validation */
492 
493     Status = AcpiUtValidateBuffer (OutBuffer);
494     if (ACPI_FAILURE (Status))
495     {
496         return_ACPI_STATUS (Status);
497     }
498 
499     /* Validate/Allocate/Clear caller buffer */
500 
501     Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO));
502     if (ACPI_FAILURE (Status))
503     {
504         return_ACPI_STATUS (Status);
505     }
506 
507     /*
508      * Populate the return buffer
509      */
510     InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer;
511 
512     InfoPtr->AcpiCaVersion = ACPI_CA_VERSION;
513 
514     /* System flags (ACPI capabilities) */
515 
516     InfoPtr->Flags = ACPI_SYS_MODE_ACPI;
517 
518     /* Timer resolution - 24 or 32 bits  */
519 
520     if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
521     {
522         InfoPtr->TimerResolution = 24;
523     }
524     else
525     {
526         InfoPtr->TimerResolution = 32;
527     }
528 
529     /* Clear the reserved fields */
530 
531     InfoPtr->Reserved1 = 0;
532     InfoPtr->Reserved2 = 0;
533 
534     /* Current debug levels */
535 
536     InfoPtr->DebugLayer = AcpiDbgLayer;
537     InfoPtr->DebugLevel = AcpiDbgLevel;
538 
539     return_ACPI_STATUS (AE_OK);
540 }
541 
542 ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo)
543 
544 
545 /*******************************************************************************
546  *
547  * FUNCTION:    AcpiGetStatistics
548  *
549  * PARAMETERS:  Stats           - Where the statistics are returned
550  *
551  * RETURN:      Status          - the status of the call
552  *
553  * DESCRIPTION: Get the contents of the various system counters
554  *
555  ******************************************************************************/
556 
557 ACPI_STATUS
558 AcpiGetStatistics (
559     ACPI_STATISTICS         *Stats)
560 {
561     ACPI_FUNCTION_TRACE (AcpiGetStatistics);
562 
563 
564     /* Parameter validation */
565 
566     if (!Stats)
567     {
568         return_ACPI_STATUS (AE_BAD_PARAMETER);
569     }
570 
571     /* Various interrupt-based event counters */
572 
573     Stats->SciCount = AcpiSciCount;
574     Stats->GpeCount = AcpiGpeCount;
575 
576     ACPI_MEMCPY (Stats->FixedEventCount, AcpiFixedEventCount,
577         sizeof (AcpiFixedEventCount));
578 
579 
580     /* Other counters */
581 
582     Stats->MethodCount = AcpiMethodCount;
583 
584     return_ACPI_STATUS (AE_OK);
585 }
586 
587 ACPI_EXPORT_SYMBOL (AcpiGetStatistics)
588 
589 
590 /*****************************************************************************
591  *
592  * FUNCTION:    AcpiInstallInitializationHandler
593  *
594  * PARAMETERS:  Handler             - Callback procedure
595  *              Function            - Not (currently) used, see below
596  *
597  * RETURN:      Status
598  *
599  * DESCRIPTION: Install an initialization handler
600  *
601  * TBD: When a second function is added, must save the Function also.
602  *
603  ****************************************************************************/
604 
605 ACPI_STATUS
606 AcpiInstallInitializationHandler (
607     ACPI_INIT_HANDLER       Handler,
608     UINT32                  Function)
609 {
610 
611     if (!Handler)
612     {
613         return (AE_BAD_PARAMETER);
614     }
615 
616     if (AcpiGbl_InitHandler)
617     {
618         return (AE_ALREADY_EXISTS);
619     }
620 
621     AcpiGbl_InitHandler = Handler;
622     return AE_OK;
623 }
624 
625 ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler)
626 
627 
628 /*****************************************************************************
629  *
630  * FUNCTION:    AcpiPurgeCachedObjects
631  *
632  * PARAMETERS:  None
633  *
634  * RETURN:      Status
635  *
636  * DESCRIPTION: Empty all caches (delete the cached objects)
637  *
638  ****************************************************************************/
639 
640 ACPI_STATUS
641 AcpiPurgeCachedObjects (
642     void)
643 {
644     ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects);
645 
646     (void) AcpiOsPurgeCache (AcpiGbl_StateCache);
647     (void) AcpiOsPurgeCache (AcpiGbl_OperandCache);
648     (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache);
649     (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache);
650     return_ACPI_STATUS (AE_OK);
651 }
652 
653 ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects)
654 
655 
656 /*****************************************************************************
657  *
658  * FUNCTION:    AcpiInstallInterface
659  *
660  * PARAMETERS:  InterfaceName       - The interface to install
661  *
662  * RETURN:      Status
663  *
664  * DESCRIPTION: Install an _OSI interface to the global list
665  *
666  ****************************************************************************/
667 
668 ACPI_STATUS
669 AcpiInstallInterface (
670     ACPI_STRING             InterfaceName)
671 {
672     ACPI_STATUS             Status;
673     ACPI_INTERFACE_INFO     *InterfaceInfo;
674 
675 
676     /* Parameter validation */
677 
678     if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0))
679     {
680         return (AE_BAD_PARAMETER);
681     }
682 
683     (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
684 
685     /* Check if the interface name is already in the global list */
686 
687     InterfaceInfo = AcpiUtGetInterface (InterfaceName);
688     if (InterfaceInfo)
689     {
690         /*
691          * The interface already exists in the list. This is OK if the
692          * interface has been marked invalid -- just clear the bit.
693          */
694         if (InterfaceInfo->Flags & ACPI_OSI_INVALID)
695         {
696             InterfaceInfo->Flags &= ~ACPI_OSI_INVALID;
697             Status = AE_OK;
698         }
699         else
700         {
701             Status = AE_ALREADY_EXISTS;
702         }
703     }
704     else
705     {
706         /* New interface name, install into the global list */
707 
708         Status = AcpiUtInstallInterface (InterfaceName);
709     }
710 
711     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
712     return (Status);
713 }
714 
715 ACPI_EXPORT_SYMBOL (AcpiInstallInterface)
716 
717 
718 /*****************************************************************************
719  *
720  * FUNCTION:    AcpiRemoveInterface
721  *
722  * PARAMETERS:  InterfaceName       - The interface to remove
723  *
724  * RETURN:      Status
725  *
726  * DESCRIPTION: Remove an _OSI interface from the global list
727  *
728  ****************************************************************************/
729 
730 ACPI_STATUS
731 AcpiRemoveInterface (
732     ACPI_STRING             InterfaceName)
733 {
734     ACPI_STATUS             Status;
735 
736 
737     /* Parameter validation */
738 
739     if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0))
740     {
741         return (AE_BAD_PARAMETER);
742     }
743 
744     (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
745 
746     Status = AcpiUtRemoveInterface (InterfaceName);
747 
748     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
749     return (Status);
750 }
751 
752 ACPI_EXPORT_SYMBOL (AcpiRemoveInterface)
753 
754 
755 /*****************************************************************************
756  *
757  * FUNCTION:    AcpiInstallInterfaceHandler
758  *
759  * PARAMETERS:  Handler             - The _OSI interface handler to install
760  *                                    NULL means "remove existing handler"
761  *
762  * RETURN:      Status
763  *
764  * DESCRIPTION: Install a handler for the predefined _OSI ACPI method.
765  *              invoked during execution of the internal implementation of
766  *              _OSI. A NULL handler simply removes any existing handler.
767  *
768  ****************************************************************************/
769 
770 ACPI_STATUS
771 AcpiInstallInterfaceHandler (
772     ACPI_INTERFACE_HANDLER  Handler)
773 {
774     ACPI_STATUS             Status = AE_OK;
775 
776 
777     (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
778 
779     if (Handler && AcpiGbl_InterfaceHandler)
780     {
781         Status = AE_ALREADY_EXISTS;
782     }
783     else
784     {
785         AcpiGbl_InterfaceHandler = Handler;
786     }
787 
788     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
789     return (Status);
790 }
791 
792 ACPI_EXPORT_SYMBOL (AcpiInstallInterfaceHandler)
793 
794 
795 /*****************************************************************************
796  *
797  * FUNCTION:    AcpiCheckAddressRange
798  *
799  * PARAMETERS:  SpaceId             - Address space ID
800  *              Address             - Start address
801  *              Length              - Length
802  *              Warn                - TRUE if warning on overlap desired
803  *
804  * RETURN:      Count of the number of conflicts detected.
805  *
806  * DESCRIPTION: Check if the input address range overlaps any of the
807  *              ASL operation region address ranges.
808  *
809  ****************************************************************************/
810 
811 UINT32
812 AcpiCheckAddressRange (
813     ACPI_ADR_SPACE_TYPE     SpaceId,
814     ACPI_PHYSICAL_ADDRESS   Address,
815     ACPI_SIZE               Length,
816     BOOLEAN                 Warn)
817 {
818     UINT32                  Overlaps;
819     ACPI_STATUS             Status;
820 
821 
822     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
823     if (ACPI_FAILURE (Status))
824     {
825         return (0);
826     }
827 
828     Overlaps = AcpiUtCheckAddressRange (SpaceId, Address,
829         (UINT32) Length, Warn);
830 
831     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
832     return (Overlaps);
833 }
834 
835 ACPI_EXPORT_SYMBOL (AcpiCheckAddressRange)
836 
837 #endif /* !ACPI_ASL_COMPILER */
838