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