ReactOS 0.4.16-dev-306-g647d351
utmutex.c File Reference
#include "acpi.h"
#include "accommon.h"
Include dependency graph for utmutex.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_UTILITIES
 

Functions

static ACPI_STATUS AcpiUtCreateMutex (ACPI_MUTEX_HANDLE MutexId)
 
static void AcpiUtDeleteMutex (ACPI_MUTEX_HANDLE MutexId)
 
ACPI_STATUS AcpiUtMutexInitialize (void)
 
void AcpiUtMutexTerminate (void)
 
ACPI_STATUS AcpiUtAcquireMutex (ACPI_MUTEX_HANDLE MutexId)
 
ACPI_STATUS AcpiUtReleaseMutex (ACPI_MUTEX_HANDLE MutexId)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_UTILITIES

Definition at line 47 of file utmutex.c.

Function Documentation

◆ AcpiUtAcquireMutex()

ACPI_STATUS AcpiUtAcquireMutex ( ACPI_MUTEX_HANDLE  MutexId)

Definition at line 256 of file utmutex.c.

258{
260 ACPI_THREAD_ID ThisThreadId;
261
262
263 ACPI_FUNCTION_NAME (UtAcquireMutex);
264
265
266 if (MutexId > ACPI_MAX_MUTEX)
267 {
268 return (AE_BAD_PARAMETER);
269 }
270
271 ThisThreadId = AcpiOsGetThreadId ();
272
273#ifdef ACPI_MUTEX_DEBUG
274 {
275 UINT32 i;
276 /*
277 * Mutex debug code, for internal debugging only.
278 *
279 * Deadlock prevention. Check if this thread owns any mutexes of value
280 * greater than or equal to this one. If so, the thread has violated
281 * the mutex ordering rule. This indicates a coding error somewhere in
282 * the ACPI subsystem code.
283 */
284 for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
285 {
286 if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId)
287 {
288 if (i == MutexId)
289 {
291 "Mutex [%s] already acquired by this thread [%u]",
292 AcpiUtGetMutexName (MutexId),
293 (UINT32) ThisThreadId));
294
295 return (AE_ALREADY_ACQUIRED);
296 }
297
299 "Invalid acquire order: Thread %u owns [%s], wants [%s]",
300 (UINT32) ThisThreadId, AcpiUtGetMutexName (i),
301 AcpiUtGetMutexName (MutexId)));
302
303 return (AE_ACQUIRE_DEADLOCK);
304 }
305 }
306 }
307#endif
308
310 "Thread %u attempting to acquire Mutex [%s]\n",
311 (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
312
314 AcpiGbl_MutexInfo[MutexId].Mutex, ACPI_WAIT_FOREVER);
315 if (ACPI_SUCCESS (Status))
316 {
318 "Thread %u acquired Mutex [%s]\n",
319 (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
320
321 AcpiGbl_MutexInfo[MutexId].UseCount++;
322 AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId;
323 }
324 else
325 {
327 "Thread %u could not acquire Mutex [%s] (0x%X)",
328 (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId), MutexId));
329 }
330
331 return (Status);
332}
unsigned int UINT32
#define AE_ALREADY_ACQUIRED
Definition: acexcep.h:129
#define AE_ACQUIRE_DEADLOCK
Definition: acexcep.h:126
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define ACPI_MAX_MUTEX
Definition: aclocal.h:91
#define ACPI_NUM_MUTEX
Definition: aclocal.h:92
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
#define ACPI_DB_MUTEX
Definition: acoutput.h:182
ACPI_THREAD_ID AcpiOsGetThreadId(void)
Definition: osl.c:217
#define AcpiOsAcquireMutex(Handle, Time)
Definition: actypes.h:276
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_WAIT_FOREVER
Definition: actypes.h:501
#define ACPI_THREAD_ID
Definition: actypes.h:144
const char * AcpiUtGetMutexName(UINT32 MutexId)
Definition: utdecode.c:479
Definition: Mutex.h:16
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by AcpiAnyGpeStatusSet(), AcpiAttachData(), AcpiCheckAddressRange(), AcpiDebugTrace(), AcpiDetachData(), AcpiDisableAllGpes(), AcpiEnableAllRuntimeGpes(), AcpiEnableAllWakeupGpes(), AcpiEvDeleteGpeBlock(), AcpiEvDetachRegion(), AcpiEvExecuteOrphanRegMethod(), AcpiEvGpeInitialize(), AcpiEvInitializeOpRegions(), AcpiEvInstallGpeBlock(), AcpiEvInstallGpeHandler(), AcpiEvInstallRegionHandlers(), AcpiEvUpdateGpes(), AcpiExEnterInterpreter(), AcpiGetData(), AcpiGetDevices(), AcpiGetName(), AcpiGetNextObject(), AcpiGetObjectInfo(), AcpiGetParent(), AcpiGetTable(), AcpiGetTableByIndex(), AcpiGetType(), AcpiInstallAddressSpaceHandler(), AcpiInstallExceptionHandler(), AcpiInstallFixedEventHandler(), AcpiInstallGlobalEventHandler(), AcpiInstallGpeBlock(), AcpiInstallMethod(), AcpiInstallNotifyHandler(), AcpiInstallSciHandler(), AcpiInstallTableHandler(), AcpiNsDeleteNamespaceByOwner(), AcpiNsDeleteNamespaceSubtree(), AcpiNsGetDeviceCallback(), AcpiNsGetNode(), AcpiNsRootInitialize(), AcpiNsTerminate(), AcpiNsWalkNamespace(), AcpiPutTable(), AcpiReallocateRootTable(), AcpiRemoveAddressSpaceHandler(), AcpiRemoveFixedEventHandler(), AcpiRemoveGpeBlock(), AcpiRemoveGpeHandler(), AcpiRemoveNotifyHandler(), AcpiRemoveSciHandler(), AcpiRemoveTableHandler(), AcpiTbAllocateOwnerId(), AcpiTbDeleteNamespaceByOwner(), AcpiTbFindTable(), AcpiTbGetOwnerId(), AcpiTbInstallStandardTable(), AcpiTbIsTableLoaded(), AcpiTbLoadNamespace(), AcpiTbReleaseOwnerId(), AcpiTbSetTableLoadedFlag(), AcpiTbTerminate(), AcpiUnloadParentTable(), AcpiUpdateAllGpes(), AcpiUtAllocateOwnerId(), AcpiUtReleaseOwnerId(), and AcpiWalkNamespace().

◆ AcpiUtCreateMutex()

static ACPI_STATUS AcpiUtCreateMutex ( ACPI_MUTEX_HANDLE  MutexId)
static

Definition at line 194 of file utmutex.c.

196{
198
199
200 ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId);
201
202
203 if (!AcpiGbl_MutexInfo[MutexId].Mutex)
204 {
205 Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex);
206 AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
207 AcpiGbl_MutexInfo[MutexId].UseCount = 0;
208 }
209
211}
#define AE_OK
Definition: acexcep.h:97
#define ACPI_MUTEX_NOT_ACQUIRED
Definition: aclocal.h:119
#define ACPI_FUNCTION_TRACE_U32(a, b)
Definition: acoutput.h:482
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define AcpiOsCreateMutex(OutHandle)
Definition: actypes.h:274

Referenced by AcpiUtMutexInitialize().

◆ AcpiUtDeleteMutex()

static void AcpiUtDeleteMutex ( ACPI_MUTEX_HANDLE  MutexId)
static

Definition at line 227 of file utmutex.c.

229{
230
231 ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId);
232
233
234 AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
235
236 AcpiGbl_MutexInfo[MutexId].Mutex = NULL;
237 AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
238
240}
#define return_VOID
Definition: acoutput.h:495
#define AcpiOsDeleteMutex(Handle)
Definition: actypes.h:275
#define NULL
Definition: types.h:112

Referenced by AcpiUtMutexTerminate().

◆ AcpiUtMutexInitialize()

ACPI_STATUS AcpiUtMutexInitialize ( void  )

Definition at line 75 of file utmutex.c.

77{
78 UINT32 i;
80
81
82 ACPI_FUNCTION_TRACE (UtMutexInitialize);
83
84
85 /* Create each of the predefined mutex objects */
86
87 for (i = 0; i < ACPI_NUM_MUTEX; i++)
88 {
90 if (ACPI_FAILURE (Status))
91 {
93 }
94 }
95
96 /* Create the spinlocks for use at interrupt level or for speed */
97
98 Status = AcpiOsCreateLock (&AcpiGbl_GpeLock);
99 if (ACPI_FAILURE (Status))
100 {
102 }
103
104 Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock);
105 if (ACPI_FAILURE (Status))
106 {
108 }
109
110 Status = AcpiOsCreateLock (&AcpiGbl_ReferenceCountLock);
111 if (ACPI_FAILURE (Status))
112 {
114 }
115
116 /* Mutex for _OSI support */
117
118 Status = AcpiOsCreateMutex (&AcpiGbl_OsiMutex);
119 if (ACPI_FAILURE (Status))
120 {
122 }
123
124 /* Create the reader/writer lock for namespace access */
125
126 Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock);
127 if (ACPI_FAILURE (Status))
128 {
130 }
131
133}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_STATUS AcpiOsCreateLock(ACPI_SPINLOCK *OutHandle)
Definition: osl.c:463
ACPI_STATUS AcpiUtCreateRwLock(ACPI_RW_LOCK *Lock)
Definition: utlock.c:66
static ACPI_STATUS AcpiUtCreateMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:194

Referenced by AcpiInitializeSubsystem().

◆ AcpiUtMutexTerminate()

void AcpiUtMutexTerminate ( void  )

Definition at line 150 of file utmutex.c.

152{
153 UINT32 i;
154
155
156 ACPI_FUNCTION_TRACE (UtMutexTerminate);
157
158
159 /* Delete each predefined mutex object */
160
161 for (i = 0; i < ACPI_NUM_MUTEX; i++)
162 {
164 }
165
166 AcpiOsDeleteMutex (AcpiGbl_OsiMutex);
167
168 /* Delete the spinlocks */
169
170 AcpiOsDeleteLock (AcpiGbl_GpeLock);
171 AcpiOsDeleteLock (AcpiGbl_HardwareLock);
172 AcpiOsDeleteLock (AcpiGbl_ReferenceCountLock);
173
174 /* Delete the reader/writer lock */
175
176 AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock);
178}
void AcpiOsDeleteLock(ACPI_SPINLOCK Handle)
Definition: osl.c:485
void AcpiUtDeleteRwLock(ACPI_RW_LOCK *Lock)
Definition: utlock.c:85
static void AcpiUtDeleteMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:227

Referenced by AcpiTerminate().

◆ AcpiUtReleaseMutex()

ACPI_STATUS AcpiUtReleaseMutex ( ACPI_MUTEX_HANDLE  MutexId)

Definition at line 348 of file utmutex.c.

350{
351 ACPI_FUNCTION_NAME (UtReleaseMutex);
352
353
354 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u releasing Mutex [%s]\n",
356
357 if (MutexId > ACPI_MAX_MUTEX)
358 {
359 return (AE_BAD_PARAMETER);
360 }
361
362 /*
363 * Mutex must be acquired in order to release it!
364 */
365 if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED)
366 {
368 "Mutex [%s] (0x%X) is not acquired, cannot release",
369 AcpiUtGetMutexName (MutexId), MutexId));
370
371 return (AE_NOT_ACQUIRED);
372 }
373
374#ifdef ACPI_MUTEX_DEBUG
375 {
376 UINT32 i;
377 /*
378 * Mutex debug code, for internal debugging only.
379 *
380 * Deadlock prevention. Check if this thread owns any mutexes of value
381 * greater than this one. If so, the thread has violated the mutex
382 * ordering rule. This indicates a coding error somewhere in
383 * the ACPI subsystem code.
384 */
385 for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
386 {
387 if (AcpiGbl_MutexInfo[i].ThreadId == AcpiOsGetThreadId ())
388 {
389 if (i == MutexId)
390 {
391 continue;
392 }
393
395 "Invalid release order: owns [%s], releasing [%s]",
397
398 return (AE_RELEASE_DEADLOCK);
399 }
400 }
401 }
402#endif
403
404 /* Mark unlocked FIRST */
405
406 AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
407
408 AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
409 return (AE_OK);
410}
#define AE_RELEASE_DEADLOCK
Definition: acexcep.h:127
#define AE_NOT_ACQUIRED
Definition: acexcep.h:128
#define AcpiOsReleaseMutex(Handle)
Definition: actypes.h:277

Referenced by AcpiAnyGpeStatusSet(), AcpiAttachData(), AcpiCheckAddressRange(), AcpiDebugTrace(), AcpiDetachData(), AcpiDisableAllGpes(), AcpiEnableAllRuntimeGpes(), AcpiEnableAllWakeupGpes(), AcpiEvDeleteGpeBlock(), AcpiEvDetachRegion(), AcpiEvExecuteOrphanRegMethod(), AcpiEvGpeInitialize(), AcpiEvInitializeOpRegions(), AcpiEvInstallGpeBlock(), AcpiEvInstallGpeHandler(), AcpiEvInstallRegionHandlers(), AcpiEvUpdateGpes(), AcpiExExitInterpreter(), AcpiGetData(), AcpiGetDevices(), AcpiGetName(), AcpiGetNextObject(), AcpiGetObjectInfo(), AcpiGetParent(), AcpiGetTable(), AcpiGetTableByIndex(), AcpiGetType(), AcpiInstallAddressSpaceHandler(), AcpiInstallExceptionHandler(), AcpiInstallFixedEventHandler(), AcpiInstallGlobalEventHandler(), AcpiInstallGpeBlock(), AcpiInstallMethod(), AcpiInstallNotifyHandler(), AcpiInstallSciHandler(), AcpiInstallTableHandler(), AcpiNsDeleteNamespaceByOwner(), AcpiNsDeleteNamespaceSubtree(), AcpiNsGetDeviceCallback(), AcpiNsGetNode(), AcpiNsRootInitialize(), AcpiNsTerminate(), AcpiNsWalkNamespace(), AcpiPutTable(), AcpiReallocateRootTable(), AcpiRemoveAddressSpaceHandler(), AcpiRemoveFixedEventHandler(), AcpiRemoveGpeBlock(), AcpiRemoveGpeHandler(), AcpiRemoveNotifyHandler(), AcpiRemoveSciHandler(), AcpiRemoveTableHandler(), AcpiTbAllocateOwnerId(), AcpiTbDeleteNamespaceByOwner(), AcpiTbFindTable(), AcpiTbGetOwnerId(), AcpiTbInstallStandardTable(), AcpiTbIsTableLoaded(), AcpiTbLoadNamespace(), AcpiTbReleaseOwnerId(), AcpiTbSetTableLoadedFlag(), AcpiTbTerminate(), AcpiUnloadParentTable(), AcpiUpdateAllGpes(), AcpiUtAllocateOwnerId(), AcpiUtReleaseOwnerId(), and AcpiWalkNamespace().