/* This function raises the system's current task priority level to the task priority level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state. If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned. Otherwise, EFI_SUCCESS is returned. If Lock is NULL, then ASSERT(). If Lock is not initialized, then ASSERT(). */
EFI_STATUS EFIAPI EfiAcquireLockOrFail(IN EFI_LOCK *Lock)
/* This function raises the system's current task priority level to the task priority level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state. If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned. Otherwise, EFI_SUCCESS is returned. If Lock is NULL, then ASSERT(). If Lock is not initialized, then ASSERT(). */
EFI_STATUS EFIAPI EfiAcquireLockOrFail(IN EFI_LOCK *Lock)
{
  ASSERT (Lock != NULL);
  ASSERT (Lock->Lock != EfiLockUninitialized);
  if (Lock->Lock == EfiLockAcquired) {
    return EFI_ACCESS_DENIED;
  }
  Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);
  Lock->Lock = EfiLockAcquired;
  return EFI_SUCCESS;
}