/******************************************************************************
*
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"
#include "acevents.h"
ACPI_MODULE_NAME ("exmutex")
/* Local prototypes */
static void
/*******************************************************************************
*
* FUNCTION: AcpiExUnlinkMutex
*
* PARAMETERS: ObjDesc - The mutex to be unlinked
*
* RETURN: None
*
* DESCRIPTION: Remove a mutex from the "AcquiredMutex" list
*
******************************************************************************/
void
{
if (!Thread)
{
return;
}
/* Doubly linked list */
{
}
{
/*
* Migrate the previous sync level associated with this mutex to
* the previous mutex on the list so that it may be preserved.
* This handles the case where several mutexes have been acquired
* at the same level, but are not released in opposite order.
*/
}
else
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiExLinkMutex
*
* PARAMETERS: ObjDesc - The mutex to be linked
* Thread - Current executing thread object
*
* RETURN: None
*
* DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk
*
******************************************************************************/
static void
{
/* This object will be the first object in the list */
/* Update old first object to point back to this object */
if (ListHead)
{
}
/* Update list head */
}
/*******************************************************************************
*
* FUNCTION: AcpiExAcquireMutexObject
*
* PARAMETERS: Timeout - Timeout in milliseconds
* ObjDesc - Mutex object
* ThreadId - Current thread state
*
* RETURN: Status
*
* DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common
* path that supports multiple acquires by the same thread.
*
* MUTEX: Interpreter must be locked
*
* NOTE: This interface is called from three places:
* 1) From AcpiExAcquireMutex, via an AML Acquire() operator
* 2) From AcpiExAcquireGlobalLock when an AML Field access requires the
* global lock
* 3) From the external interface, AcpiAcquireGlobalLock
*
******************************************************************************/
{
if (!ObjDesc)
{
}
/* Support for multiple acquires by the owning thread */
{
/*
* The mutex is already owned by this thread, just increment the
* acquisition depth
*/
}
/* Acquire the mutex, wait if necessary. Special case for Global Lock */
if (ObjDesc == AcpiGbl_GlobalLockMutex)
{
}
else
{
}
if (ACPI_FAILURE (Status))
{
/* Includes failure from a timeout on TimeDesc */
}
/* Acquired the mutex: update mutex object */
}
/*******************************************************************************
*
* FUNCTION: AcpiExAcquireMutex
*
* PARAMETERS: TimeDesc - Timeout integer
* ObjDesc - Mutex object
* WalkState - Current method execution state
*
* RETURN: Status
*
* DESCRIPTION: Acquire an AML mutex
*
******************************************************************************/
{
if (!ObjDesc)
{
}
/* Must have a valid thread state struct */
{
"Cannot acquire Mutex [%4.4s], null thread info",
}
/*
* Current sync level must be less than or equal to the sync level
* of the mutex. This mechanism provides some deadlock prevention.
*/
{
"Cannot acquire Mutex [%4.4s], "
"current SyncLevel is too large (%u)",
}
"Acquiring: Mutex SyncLevel %u, Thread SyncLevel %u, "
"Depth %u TID %p\n",
{
/* Link the mutex to the current thread for force-unlock at method exit */
}
"Acquired: Mutex SyncLevel %u, Thread SyncLevel %u, Depth %u\n",
}
/*******************************************************************************
*
* FUNCTION: AcpiExReleaseMutexObject
*
* PARAMETERS: ObjDesc - The object descriptor for this op
*
* RETURN: Status
*
* DESCRIPTION: Release a previously acquired Mutex, low level interface.
* Provides a common path that supports multiple releases (after
* previous multiple acquires) by the same thread.
*
* MUTEX: Interpreter must be locked
*
* NOTE: This interface is called from three places:
* 1) From AcpiExReleaseMutex, via an AML Acquire() operator
* 2) From AcpiExReleaseGlobalLock when an AML Field access requires the
* global lock
* 3) From the external interface, AcpiReleaseGlobalLock
*
******************************************************************************/
{
{
}
/* Match multiple Acquires with multiple Releases */
{
/* Just decrement the depth and return */
}
{
/* Unlink the mutex from the owner's list */
}
/* Release the mutex, special case for Global Lock */
if (ObjDesc == AcpiGbl_GlobalLockMutex)
{
}
else
{
}
/* Clear mutex info */
}
/*******************************************************************************
*
* FUNCTION: AcpiExReleaseMutex
*
* PARAMETERS: ObjDesc - The object descriptor for this op
* WalkState - Current method execution state
*
* RETURN: Status
*
* DESCRIPTION: Release a previously acquired Mutex.
*
******************************************************************************/
{
if (!ObjDesc)
{
}
/* The mutex must have been previously acquired in order to release it */
if (!OwnerThread)
{
"Cannot release Mutex [%4.4s], not acquired",
}
/* Must have a valid thread ID */
{
"Cannot release Mutex [%4.4s], null thread info",
}
/*
* The Mutex is owned, but this thread must be the owner.
* Special case for Global Lock, any thread can release
*/
{
"Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
}
/*
* The sync level of the mutex must be equal to the current sync level. In
* other words, the current level means that at least one mutex at that
* level is currently being held. Attempting to release a mutex of a
* different level can only mean that the mutex ordering rule is being
* violated. This behavior is clarified in ACPI 4.0 specification.
*/
{
"Cannot release Mutex [%4.4s], SyncLevel mismatch: "
"mutex %u current %u",
}
/*
* Get the previous SyncLevel from the head of the acquired mutex list.
* This handles the case where several mutexes at the same level have been
* acquired, but are not released in reverse order.
*/
"Releasing: Object SyncLevel %u, Thread SyncLevel %u, "
"Prev SyncLevel %u, Depth %u TID %p\n",
if (ACPI_FAILURE (Status))
{
}
{
/* Restore the previous SyncLevel */
}
"Released: Object SyncLevel %u, Thread SyncLevel, %u, "
"Prev SyncLevel %u, Depth %u\n",
}
/*******************************************************************************
*
* FUNCTION: AcpiExReleaseAllMutexes
*
* PARAMETERS: Thread - Current executing thread object
*
* RETURN: Status
*
* DESCRIPTION: Release all mutexes held by this thread
*
* NOTE: This function is called as the thread is exiting the interpreter.
* Mutexes are not released when an individual control method is exited, but
* only when the parent thread actually exits the interpreter. This allows one
* method to acquire a mutex, and a different method to release it, as long as
* this is performed underneath a single parent control method.
*
******************************************************************************/
void
{
/* Traverse the list of owned mutexes, releasing each one */
while (Next)
{
"Mutex [%4.4s] force-release, SyncLevel %u Depth %u\n",
/* Release the mutex, special case for Global Lock */
if (ObjDesc == AcpiGbl_GlobalLockMutex)
{
/* Ignore errors */
(void) AcpiEvReleaseGlobalLock ();
}
else
{
}
/* Update Thread SyncLevel (Last mutex is the important one) */
/* Mark mutex unowned */
}
}