1 /******************************************************************************
3 * Module Name: evxface - External interfaces for ACPI events
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2011, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
47 #include <contrib/dev/acpica/include/acpi.h>
48 #include <contrib/dev/acpica/include/accommon.h>
49 #include <contrib/dev/acpica/include/acnamesp.h>
50 #include <contrib/dev/acpica/include/acevents.h>
51 #include <contrib/dev/acpica/include/acinterp.h>
53 #define _COMPONENT ACPI_EVENTS
54 ACPI_MODULE_NAME ("evxface")
57 /*******************************************************************************
59 * FUNCTION: AcpiInstallExceptionHandler
61 * PARAMETERS: Handler - Pointer to the handler function for the
66 * DESCRIPTION: Saves the pointer to the handler function
68 ******************************************************************************/
71 AcpiInstallExceptionHandler (
72 ACPI_EXCEPTION_HANDLER Handler)
77 ACPI_FUNCTION_TRACE (AcpiInstallExceptionHandler);
80 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
81 if (ACPI_FAILURE (Status))
83 return_ACPI_STATUS (Status);
86 /* Don't allow two handlers. */
88 if (AcpiGbl_ExceptionHandler)
90 Status = AE_ALREADY_EXISTS;
94 /* Install the handler */
96 AcpiGbl_ExceptionHandler = Handler;
99 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
100 return_ACPI_STATUS (Status);
103 ACPI_EXPORT_SYMBOL (AcpiInstallExceptionHandler)
106 /*******************************************************************************
108 * FUNCTION: AcpiInstallGlobalEventHandler
110 * PARAMETERS: Handler - Pointer to the global event handler function
111 * Context - Value passed to the handler on each event
115 * DESCRIPTION: Saves the pointer to the handler function. The global handler
116 * is invoked upon each incoming GPE and Fixed Event. It is
117 * invoked at interrupt level at the time of the event dispatch.
118 * Can be used to update event counters, etc.
120 ******************************************************************************/
123 AcpiInstallGlobalEventHandler (
124 ACPI_GBL_EVENT_HANDLER Handler,
130 ACPI_FUNCTION_TRACE (AcpiInstallGlobalEventHandler);
133 /* Parameter validation */
137 return_ACPI_STATUS (AE_BAD_PARAMETER);
140 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
141 if (ACPI_FAILURE (Status))
143 return_ACPI_STATUS (Status);
146 /* Don't allow two handlers. */
148 if (AcpiGbl_GlobalEventHandler)
150 Status = AE_ALREADY_EXISTS;
154 AcpiGbl_GlobalEventHandler = Handler;
155 AcpiGbl_GlobalEventHandlerContext = Context;
159 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
160 return_ACPI_STATUS (Status);
163 ACPI_EXPORT_SYMBOL (AcpiInstallGlobalEventHandler)
166 /*******************************************************************************
168 * FUNCTION: AcpiInstallFixedEventHandler
170 * PARAMETERS: Event - Event type to enable.
171 * Handler - Pointer to the handler function for the
173 * Context - Value passed to the handler on each GPE
177 * DESCRIPTION: Saves the pointer to the handler function and then enables the
180 ******************************************************************************/
183 AcpiInstallFixedEventHandler (
185 ACPI_EVENT_HANDLER Handler,
191 ACPI_FUNCTION_TRACE (AcpiInstallFixedEventHandler);
194 /* Parameter validation */
196 if (Event > ACPI_EVENT_MAX)
198 return_ACPI_STATUS (AE_BAD_PARAMETER);
201 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
202 if (ACPI_FAILURE (Status))
204 return_ACPI_STATUS (Status);
207 /* Don't allow two handlers. */
209 if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler)
211 Status = AE_ALREADY_EXISTS;
215 /* Install the handler before enabling the event */
217 AcpiGbl_FixedEventHandlers[Event].Handler = Handler;
218 AcpiGbl_FixedEventHandlers[Event].Context = Context;
220 Status = AcpiEnableEvent (Event, 0);
221 if (ACPI_FAILURE (Status))
223 ACPI_WARNING ((AE_INFO, "Could not enable fixed event 0x%X", Event));
225 /* Remove the handler */
227 AcpiGbl_FixedEventHandlers[Event].Handler = NULL;
228 AcpiGbl_FixedEventHandlers[Event].Context = NULL;
232 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
233 "Enabled fixed event %X, Handler=%p\n", Event, Handler));
238 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
239 return_ACPI_STATUS (Status);
242 ACPI_EXPORT_SYMBOL (AcpiInstallFixedEventHandler)
245 /*******************************************************************************
247 * FUNCTION: AcpiRemoveFixedEventHandler
249 * PARAMETERS: Event - Event type to disable.
250 * Handler - Address of the handler
254 * DESCRIPTION: Disables the event and unregisters the event handler.
256 ******************************************************************************/
259 AcpiRemoveFixedEventHandler (
261 ACPI_EVENT_HANDLER Handler)
263 ACPI_STATUS Status = AE_OK;
266 ACPI_FUNCTION_TRACE (AcpiRemoveFixedEventHandler);
269 /* Parameter validation */
271 if (Event > ACPI_EVENT_MAX)
273 return_ACPI_STATUS (AE_BAD_PARAMETER);
276 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
277 if (ACPI_FAILURE (Status))
279 return_ACPI_STATUS (Status);
282 /* Disable the event before removing the handler */
284 Status = AcpiDisableEvent (Event, 0);
286 /* Always Remove the handler */
288 AcpiGbl_FixedEventHandlers[Event].Handler = NULL;
289 AcpiGbl_FixedEventHandlers[Event].Context = NULL;
291 if (ACPI_FAILURE (Status))
293 ACPI_WARNING ((AE_INFO,
294 "Could not write to fixed event enable register 0x%X", Event));
298 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X\n", Event));
301 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
302 return_ACPI_STATUS (Status);
305 ACPI_EXPORT_SYMBOL (AcpiRemoveFixedEventHandler)
308 /*******************************************************************************
310 * FUNCTION: AcpiInstallNotifyHandler
312 * PARAMETERS: Device - The device for which notifies will be handled
313 * HandlerType - The type of handler:
314 * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f)
315 * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff)
316 * ACPI_ALL_NOTIFY: both system and device
317 * Handler - Address of the handler
318 * Context - Value passed to the handler on each GPE
322 * DESCRIPTION: Install a handler for notifies on an ACPI device
324 ******************************************************************************/
327 AcpiInstallNotifyHandler (
330 ACPI_NOTIFY_HANDLER Handler,
333 ACPI_OPERAND_OBJECT *ObjDesc;
334 ACPI_OPERAND_OBJECT *NotifyObj;
335 ACPI_NAMESPACE_NODE *Node;
339 ACPI_FUNCTION_TRACE (AcpiInstallNotifyHandler);
342 /* Parameter validation */
346 (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE))
348 return_ACPI_STATUS (AE_BAD_PARAMETER);
351 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
352 if (ACPI_FAILURE (Status))
354 return_ACPI_STATUS (Status);
357 /* Convert and validate the device handle */
359 Node = AcpiNsValidateHandle (Device);
362 Status = AE_BAD_PARAMETER;
368 * Registering a notify handler on the root object indicates that the
369 * caller wishes to receive notifications for all objects. Note that
370 * only one <external> global handler can be regsitered (per notify type).
372 if (Device == ACPI_ROOT_OBJECT)
374 /* Make sure the handler is not already installed */
376 if (((HandlerType & ACPI_SYSTEM_NOTIFY) &&
377 AcpiGbl_SystemNotify.Handler) ||
378 ((HandlerType & ACPI_DEVICE_NOTIFY) &&
379 AcpiGbl_DeviceNotify.Handler))
381 Status = AE_ALREADY_EXISTS;
385 if (HandlerType & ACPI_SYSTEM_NOTIFY)
387 AcpiGbl_SystemNotify.Node = Node;
388 AcpiGbl_SystemNotify.Handler = Handler;
389 AcpiGbl_SystemNotify.Context = Context;
392 if (HandlerType & ACPI_DEVICE_NOTIFY)
394 AcpiGbl_DeviceNotify.Node = Node;
395 AcpiGbl_DeviceNotify.Handler = Handler;
396 AcpiGbl_DeviceNotify.Context = Context;
399 /* Global notify handler installed */
404 * Caller will only receive notifications specific to the target object.
405 * Note that only certain object types can receive notifications.
409 /* Notifies allowed on this object? */
411 if (!AcpiEvIsNotifyObject (Node))
417 /* Check for an existing internal object */
419 ObjDesc = AcpiNsGetAttachedObject (Node);
422 /* Object exists - make sure there's no handler */
424 if (((HandlerType & ACPI_SYSTEM_NOTIFY) &&
425 ObjDesc->CommonNotify.SystemNotify) ||
426 ((HandlerType & ACPI_DEVICE_NOTIFY) &&
427 ObjDesc->CommonNotify.DeviceNotify))
429 Status = AE_ALREADY_EXISTS;
435 /* Create a new object */
437 ObjDesc = AcpiUtCreateInternalObject (Node->Type);
440 Status = AE_NO_MEMORY;
444 /* Attach new object to the Node */
446 Status = AcpiNsAttachObject (Device, ObjDesc, Node->Type);
448 /* Remove local reference to the object */
450 AcpiUtRemoveReference (ObjDesc);
451 if (ACPI_FAILURE (Status))
457 /* Install the handler */
459 NotifyObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_NOTIFY);
462 Status = AE_NO_MEMORY;
466 NotifyObj->Notify.Node = Node;
467 NotifyObj->Notify.Handler = Handler;
468 NotifyObj->Notify.Context = Context;
470 if (HandlerType & ACPI_SYSTEM_NOTIFY)
472 ObjDesc->CommonNotify.SystemNotify = NotifyObj;
475 if (HandlerType & ACPI_DEVICE_NOTIFY)
477 ObjDesc->CommonNotify.DeviceNotify = NotifyObj;
480 if (HandlerType == ACPI_ALL_NOTIFY)
482 /* Extra ref if installed in both */
484 AcpiUtAddReference (NotifyObj);
490 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
491 return_ACPI_STATUS (Status);
494 ACPI_EXPORT_SYMBOL (AcpiInstallNotifyHandler)
497 /*******************************************************************************
499 * FUNCTION: AcpiRemoveNotifyHandler
501 * PARAMETERS: Device - The device for which notifies will be handled
502 * HandlerType - The type of handler:
503 * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f)
504 * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff)
505 * ACPI_ALL_NOTIFY: both system and device
506 * Handler - Address of the handler
510 * DESCRIPTION: Remove a handler for notifies on an ACPI device
512 ******************************************************************************/
515 AcpiRemoveNotifyHandler (
518 ACPI_NOTIFY_HANDLER Handler)
520 ACPI_OPERAND_OBJECT *NotifyObj;
521 ACPI_OPERAND_OBJECT *ObjDesc;
522 ACPI_NAMESPACE_NODE *Node;
526 ACPI_FUNCTION_TRACE (AcpiRemoveNotifyHandler);
529 /* Parameter validation */
533 (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE))
535 return_ACPI_STATUS (AE_BAD_PARAMETER);
538 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
539 if (ACPI_FAILURE (Status))
541 return_ACPI_STATUS (Status);
544 /* Convert and validate the device handle */
546 Node = AcpiNsValidateHandle (Device);
549 Status = AE_BAD_PARAMETER;
555 if (Device == ACPI_ROOT_OBJECT)
557 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
558 "Removing notify handler for namespace root object\n"));
560 if (((HandlerType & ACPI_SYSTEM_NOTIFY) &&
561 !AcpiGbl_SystemNotify.Handler) ||
562 ((HandlerType & ACPI_DEVICE_NOTIFY) &&
563 !AcpiGbl_DeviceNotify.Handler))
565 Status = AE_NOT_EXIST;
569 if (HandlerType & ACPI_SYSTEM_NOTIFY)
571 AcpiGbl_SystemNotify.Node = NULL;
572 AcpiGbl_SystemNotify.Handler = NULL;
573 AcpiGbl_SystemNotify.Context = NULL;
576 if (HandlerType & ACPI_DEVICE_NOTIFY)
578 AcpiGbl_DeviceNotify.Node = NULL;
579 AcpiGbl_DeviceNotify.Handler = NULL;
580 AcpiGbl_DeviceNotify.Context = NULL;
584 /* All Other Objects */
588 /* Notifies allowed on this object? */
590 if (!AcpiEvIsNotifyObject (Node))
596 /* Check for an existing internal object */
598 ObjDesc = AcpiNsGetAttachedObject (Node);
601 Status = AE_NOT_EXIST;
605 /* Object exists - make sure there's an existing handler */
607 if (HandlerType & ACPI_SYSTEM_NOTIFY)
609 NotifyObj = ObjDesc->CommonNotify.SystemNotify;
612 Status = AE_NOT_EXIST;
616 if (NotifyObj->Notify.Handler != Handler)
618 Status = AE_BAD_PARAMETER;
622 /* Remove the handler */
624 ObjDesc->CommonNotify.SystemNotify = NULL;
625 AcpiUtRemoveReference (NotifyObj);
628 if (HandlerType & ACPI_DEVICE_NOTIFY)
630 NotifyObj = ObjDesc->CommonNotify.DeviceNotify;
633 Status = AE_NOT_EXIST;
637 if (NotifyObj->Notify.Handler != Handler)
639 Status = AE_BAD_PARAMETER;
643 /* Remove the handler */
645 ObjDesc->CommonNotify.DeviceNotify = NULL;
646 AcpiUtRemoveReference (NotifyObj);
652 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
653 return_ACPI_STATUS (Status);
656 ACPI_EXPORT_SYMBOL (AcpiRemoveNotifyHandler)
659 /*******************************************************************************
661 * FUNCTION: AcpiInstallGpeHandler
663 * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT
665 * GpeNumber - The GPE number within the GPE block
666 * Type - Whether this GPE should be treated as an
667 * edge- or level-triggered interrupt.
668 * Address - Address of the handler
669 * Context - Value passed to the handler on each GPE
673 * DESCRIPTION: Install a handler for a General Purpose Event.
675 ******************************************************************************/
678 AcpiInstallGpeHandler (
679 ACPI_HANDLE GpeDevice,
682 ACPI_GPE_HANDLER Address,
685 ACPI_GPE_EVENT_INFO *GpeEventInfo;
686 ACPI_GPE_HANDLER_INFO *Handler;
688 ACPI_CPU_FLAGS Flags;
691 ACPI_FUNCTION_TRACE (AcpiInstallGpeHandler);
694 /* Parameter validation */
696 if ((!Address) || (Type & ~ACPI_GPE_XRUPT_TYPE_MASK))
698 return_ACPI_STATUS (AE_BAD_PARAMETER);
701 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
702 if (ACPI_FAILURE (Status))
704 return_ACPI_STATUS (Status);
707 /* Allocate and init handler object (before lock) */
709 Handler = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_HANDLER_INFO));
712 Status = AE_NO_MEMORY;
716 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
718 /* Ensure that we have a valid GPE number */
720 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
723 Status = AE_BAD_PARAMETER;
727 /* Make sure that there isn't a handler there already */
729 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
730 ACPI_GPE_DISPATCH_HANDLER)
732 Status = AE_ALREADY_EXISTS;
736 Handler->Address = Address;
737 Handler->Context = Context;
738 Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode;
739 Handler->OriginalFlags = (UINT8) (GpeEventInfo->Flags &
740 (ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK));
743 * If the GPE is associated with a method, it may have been enabled
744 * automatically during initialization, in which case it has to be
745 * disabled now to avoid spurious execution of the handler.
747 if (((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) ||
748 (Handler->OriginalFlags & ACPI_GPE_DISPATCH_NOTIFY)) &&
749 GpeEventInfo->RuntimeCount)
751 Handler->OriginallyEnabled = TRUE;
752 (void) AcpiEvRemoveGpeReference (GpeEventInfo);
754 /* Sanity check of original type against new type */
756 if (Type != (UINT32) (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK))
758 ACPI_WARNING ((AE_INFO, "GPE type mismatch (level/edge)"));
762 /* Install the handler */
764 GpeEventInfo->Dispatch.Handler = Handler;
766 /* Setup up dispatch flags to indicate handler (vs. method/notify) */
768 GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
769 GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER);
771 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
775 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
776 return_ACPI_STATUS (Status);
779 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
784 ACPI_EXPORT_SYMBOL (AcpiInstallGpeHandler)
787 /*******************************************************************************
789 * FUNCTION: AcpiRemoveGpeHandler
791 * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT
793 * GpeNumber - The event to remove a handler
794 * Address - Address of the handler
798 * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent.
800 ******************************************************************************/
803 AcpiRemoveGpeHandler (
804 ACPI_HANDLE GpeDevice,
806 ACPI_GPE_HANDLER Address)
808 ACPI_GPE_EVENT_INFO *GpeEventInfo;
809 ACPI_GPE_HANDLER_INFO *Handler;
811 ACPI_CPU_FLAGS Flags;
814 ACPI_FUNCTION_TRACE (AcpiRemoveGpeHandler);
817 /* Parameter validation */
821 return_ACPI_STATUS (AE_BAD_PARAMETER);
824 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
825 if (ACPI_FAILURE (Status))
827 return_ACPI_STATUS (Status);
830 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
832 /* Ensure that we have a valid GPE number */
834 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
837 Status = AE_BAD_PARAMETER;
841 /* Make sure that a handler is indeed installed */
843 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) !=
844 ACPI_GPE_DISPATCH_HANDLER)
846 Status = AE_NOT_EXIST;
850 /* Make sure that the installed handler is the same */
852 if (GpeEventInfo->Dispatch.Handler->Address != Address)
854 Status = AE_BAD_PARAMETER;
858 /* Remove the handler */
860 Handler = GpeEventInfo->Dispatch.Handler;
862 /* Restore Method node (if any), set dispatch flags */
864 GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode;
865 GpeEventInfo->Flags &=
866 ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
867 GpeEventInfo->Flags |= Handler->OriginalFlags;
870 * If the GPE was previously associated with a method and it was
871 * enabled, it should be enabled at this point to restore the
872 * post-initialization configuration.
874 if ((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) &&
875 Handler->OriginallyEnabled)
877 (void) AcpiEvAddGpeReference (GpeEventInfo);
880 /* Now we can free the handler object */
886 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
887 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
888 return_ACPI_STATUS (Status);
891 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeHandler)
894 /*******************************************************************************
896 * FUNCTION: AcpiAcquireGlobalLock
898 * PARAMETERS: Timeout - How long the caller is willing to wait
899 * Handle - Where the handle to the lock is returned
904 * DESCRIPTION: Acquire the ACPI Global Lock
906 * Note: Allows callers with the same thread ID to acquire the global lock
907 * multiple times. In other words, externally, the behavior of the global lock
908 * is identical to an AML mutex. On the first acquire, a new handle is
909 * returned. On any subsequent calls to acquire by the same thread, the same
910 * handle is returned.
912 ******************************************************************************/
915 AcpiAcquireGlobalLock (
924 return (AE_BAD_PARAMETER);
927 /* Must lock interpreter to prevent race conditions */
929 AcpiExEnterInterpreter ();
931 Status = AcpiExAcquireMutexObject (Timeout,
932 AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
934 if (ACPI_SUCCESS (Status))
936 /* Return the global lock handle (updated in AcpiEvAcquireGlobalLock) */
938 *Handle = AcpiGbl_GlobalLockHandle;
941 AcpiExExitInterpreter ();
945 ACPI_EXPORT_SYMBOL (AcpiAcquireGlobalLock)
948 /*******************************************************************************
950 * FUNCTION: AcpiReleaseGlobalLock
952 * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock
956 * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid.
958 ******************************************************************************/
961 AcpiReleaseGlobalLock (
967 if (!Handle || (Handle != AcpiGbl_GlobalLockHandle))
969 return (AE_NOT_ACQUIRED);
972 Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
976 ACPI_EXPORT_SYMBOL (AcpiReleaseGlobalLock)