/** @file\r
Implementation of synchronization functions.\r
\r
- Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
optimal spin lock performance.\r
\r
This function retrieves the spin lock alignment requirements for optimal\r
- performance on a given CPU architecture. The spin lock alignment is byte alignment. \r
+ performance on a given CPU architecture. The spin lock alignment is byte alignment.\r
It must be a power of two and is returned by this function. If there are no alignment\r
requirements, then 1 must be returned. The spin lock synchronization\r
functions must function correctly if the spin lock size and alignment values\r
INT64 Cycle;\r
INT64 Delta;\r
\r
- if (PcdGet32 (PcdSpinLockTimeout) > 0) {\r
+ if (PcdGet32 (PcdSpinLockTimeout) == 0) {\r
+ while (!AcquireSpinLockOrFail (SpinLock)) {\r
+ CpuPause ();\r
+ }\r
+ } else if (!AcquireSpinLockOrFail (SpinLock)) {\r
//\r
// Get the current timer value\r
//\r
Total += Delta;\r
ASSERT (Total < Timeout);\r
}\r
- } else {\r
- while (!AcquireSpinLockOrFail (SpinLock)) {\r
- CpuPause ();\r
- }\r
}\r
return SpinLock;\r
}\r
\r
Performs an atomic increment of the 32-bit unsigned integer specified by\r
Value and returns the incremented value. The increment operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
+ performed using MP safe mechanisms.\r
\r
If Value is NULL, then ASSERT().\r
\r
UINT32\r
EFIAPI\r
InterlockedIncrement (\r
- IN UINT32 *Value\r
+ IN volatile UINT32 *Value\r
)\r
{\r
ASSERT (Value != NULL);\r
\r
Performs an atomic decrement of the 32-bit unsigned integer specified by\r
Value and returns the decremented value. The decrement operation must be\r
- performed using MP safe mechanisms. The state of the return value is not\r
- guaranteed to be MP safe.\r
+ performed using MP safe mechanisms.\r
\r
If Value is NULL, then ASSERT().\r
\r
UINT32\r
EFIAPI\r
InterlockedDecrement (\r
- IN UINT32 *Value\r
+ IN volatile UINT32 *Value\r
)\r
{\r
ASSERT (Value != NULL);\r
UINT16\r
EFIAPI\r
InterlockedCompareExchange16 (\r
- IN OUT UINT16 *Value,\r
+ IN OUT volatile UINT16 *Value,\r
IN UINT16 CompareValue,\r
IN UINT16 ExchangeValue\r
)\r
UINT32\r
EFIAPI\r
InterlockedCompareExchange32 (\r
- IN OUT UINT32 *Value,\r
+ IN OUT volatile UINT32 *Value,\r
IN UINT32 CompareValue,\r
IN UINT32 ExchangeValue\r
)\r
UINT64\r
EFIAPI\r
InterlockedCompareExchange64 (\r
- IN OUT UINT64 *Value,\r
+ IN OUT volatile UINT64 *Value,\r
IN UINT64 CompareValue,\r
IN UINT64 ExchangeValue\r
)\r
VOID *\r
EFIAPI\r
InterlockedCompareExchangePointer (\r
- IN OUT VOID **Value,\r
+ IN OUT VOID * volatile *Value,\r
IN VOID *CompareValue,\r
IN VOID *ExchangeValue\r
)\r
switch (SizeOfValue) {\r
case sizeof (UINT32):\r
return (VOID*)(UINTN)InterlockedCompareExchange32 (\r
- (UINT32*)Value,\r
+ (volatile UINT32 *)Value,\r
(UINT32)(UINTN)CompareValue,\r
(UINT32)(UINTN)ExchangeValue\r
);\r
case sizeof (UINT64):\r
return (VOID*)(UINTN)InterlockedCompareExchange64 (\r
- (UINT64*)Value,\r
+ (volatile UINT64 *)Value,\r
(UINT64)(UINTN)CompareValue,\r
(UINT64)(UINTN)ExchangeValue\r
);\r