ACPI_STATUS AcpiExSystemWaitEvent ( ACPI_OPERAND_OBJECT *TimeDesc, ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE (ExSystemWaitEvent); if (ObjDesc) { Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore, (UINT16) TimeDesc->Integer.Value); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiEvAcquireGlobalLock ( UINT16 Timeout) { ACPI_CPU_FLAGS Flags; ACPI_STATUS Status; BOOLEAN Acquired = FALSE; ACPI_FUNCTION_TRACE (EvAcquireGlobalLock); /* * Only one thread can acquire the GL at a time, the GlobalLockMutex * enforces this. This interface releases the interpreter if we must wait. */ Status = AcpiExSystemWaitMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex, Timeout); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Update the global lock handle and check for wraparound. The handle is * only used for the external global lock interfaces, but it is updated * here to properly handle the case where a single thread may acquire the * lock via both the AML and the AcpiAcquireGlobalLock interfaces. The * handle is therefore updated on the first acquire from a given thread * regardless of where the acquisition request originated. */ AcpiGbl_GlobalLockHandle++; if (AcpiGbl_GlobalLockHandle == 0) { AcpiGbl_GlobalLockHandle = 1; } /* * Make sure that a global lock actually exists. If not, just * treat the lock as a standard mutex. */ if (!AcpiGbl_GlobalLockPresent) { AcpiGbl_GlobalLockAcquired = TRUE; return_ACPI_STATUS (AE_OK); } Flags = AcpiOsAcquireLock (AcpiGbl_GlobalLockPendingLock); do { /* Attempt to acquire the actual hardware lock */ ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired); if (Acquired) { AcpiGbl_GlobalLockAcquired = TRUE; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired hardware Global Lock\n")); break; } /* * Did not get the lock. The pending bit was set above, and * we must now wait until we receive the global lock * released interrupt. */ AcpiGbl_GlobalLockPending = TRUE; AcpiOsReleaseLock (AcpiGbl_GlobalLockPendingLock, Flags); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for hardware Global Lock\n")); /* * Wait for handshake with the global lock interrupt handler. * This interface releases the interpreter if we must wait. */ Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, ACPI_WAIT_FOREVER); Flags = AcpiOsAcquireLock (AcpiGbl_GlobalLockPendingLock); } while (ACPI_SUCCESS (Status)); AcpiGbl_GlobalLockPending = FALSE; AcpiOsReleaseLock (AcpiGbl_GlobalLockPendingLock, Flags); return_ACPI_STATUS (Status); }