FreeRTOS port on GAP8/RISC-V
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
atomic.h File Reference

FreeRTOS atomic operation support. More...

Macros

#define ATOMIC_ENTER_CRITICAL()
 
#define ATOMIC_EXIT_CRITICAL()
 
#define portFORCE_INLINE
 
#define ATOMIC_COMPARE_AND_SWAP_SUCCESS
 
#define ATOMIC_COMPARE_AND_SWAP_FAILURE
 

Functions

static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32 (uint32_t volatile *pDestination, uint32_t ulExchange, uint32_t ulComparand)
 Performs an atomic compare-and-swap operation on the specified values. More...
 
static portFORCE_INLINE void * Atomic_SwapPointers_p32 (void *volatile *ppDestination, void *pExchange)
 Atomically sets the address pointed to by *ppDestination to the value of *pExchange. More...
 
static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32 (void *volatile *ppDestination, void *pExchange, void *pComparand)
 Performs an atomic compare-and-swap operation on the specified pointer values. More...
 
static portFORCE_INLINE uint32_t Atomic_Add_u32 (uint32_t volatile *pAddend, uint32_t ulCount)
 Atomically adds count to the value of the specified pointer points to. More...
 
static portFORCE_INLINE uint32_t Atomic_Subtract_u32 (uint32_t volatile *pAddend, uint32_t ulCount)
 Atomically subtracts count from the value of the specified pointer pointers to. More...
 
static portFORCE_INLINE uint32_t Atomic_Increment_u32 (uint32_t volatile *pAddend)
 Atomically increments the value of the specified pointer points to. More...
 
static portFORCE_INLINE uint32_t Atomic_Decrement_u32 (uint32_t volatile *pAddend)
 Atomically decrements the value of the specified pointer points to. More...
 
static portFORCE_INLINE uint32_t Atomic_OR_u32 (uint32_t volatile *pDestination, uint32_t ulValue)
 Performs an atomic OR operation on the specified values. More...
 
static portFORCE_INLINE uint32_t Atomic_AND_u32 (uint32_t volatile *pDestination, uint32_t ulValue)
 Performs an atomic AND operation on the specified values. More...
 
static portFORCE_INLINE uint32_t Atomic_NAND_u32 (uint32_t volatile *pDestination, uint32_t ulValue)
 Performs an atomic NAND operation on the specified values. More...
 
static portFORCE_INLINE uint32_t Atomic_XOR_u32 (uint32_t volatile *pDestination, uint32_t ulValue)
 Performs an atomic XOR operation on the specified values. More...
 

Description

This file implements atomic by disabling interrupts globally. Implementation with architecture specific atomic instructions are to be provided under each compiler directory.

Macro Definition Documentation

#define ATOMIC_COMPARE_AND_SWAP_FAILURE

Compare and swap failed, did not swap.

Referenced by Atomic_CompareAndSwap_u32(), and Atomic_CompareAndSwapPointers_p32().

#define ATOMIC_COMPARE_AND_SWAP_SUCCESS

Compare and swap succeeded, swapped.

Referenced by Atomic_CompareAndSwap_u32(), and Atomic_CompareAndSwapPointers_p32().

#define portFORCE_INLINE

Function Documentation

static portFORCE_INLINE uint32_t Atomic_Add_u32 ( uint32_t volatile *  pAddend,
uint32_t  ulCount 
)
static

Atomic add

Parameters
[in,out]pAddendPointer to memory location from where value is to be loaded and written back to.
[in]ulCountValue to be added to *pAddend.
Returns
previous *pAddend value.

References ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE uint32_t Atomic_AND_u32 ( uint32_t volatile *  pDestination,
uint32_t  ulValue 
)
static

Atomic AND

Parameters
[in,out]pDestinationPointer to memory location from where value is to be loaded and written back to.
[in]ulValueValue to be ANDed with *pDestination.
Returns
The original value of *pDestination.

References ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32 ( uint32_t volatile *  pDestination,
uint32_t  ulExchange,
uint32_t  ulComparand 
)
static

Atomic compare-and-swap

Parameters
[in,out]pDestinationPointer to memory location from where value is to be loaded and checked.
[in]ulExchangeIf condition meets, write this value to memory.
[in]ulComparandSwap condition.
Returns
Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
Note
This function only swaps *pDestination with ulExchange, if previous *pDestination value equals ulComparand.

References ATOMIC_COMPARE_AND_SWAP_FAILURE, ATOMIC_COMPARE_AND_SWAP_SUCCESS, ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32 ( void *volatile *  ppDestination,
void *  pExchange,
void *  pComparand 
)
static

Atomic compare-and-swap (pointers)

Parameters
[in,out]ppDestinationPointer to memory location from where a pointer value is to be loaded and checked.
[in]pExchangeIf condition meets, write this value to memory.
[in]pComparandSwap condition.
Returns
Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
Note
This function only swaps *ppDestination with pExchange, if previous *ppDestination value equals pComparand.

References ATOMIC_COMPARE_AND_SWAP_FAILURE, ATOMIC_COMPARE_AND_SWAP_SUCCESS, ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE uint32_t Atomic_Decrement_u32 ( uint32_t volatile *  pAddend)
static

Atomic decrement

Parameters
[in,out]pAddendPointer to memory location from where value is to be loaded and written back to.
Returns
*pAddend value before decrement.

References ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE uint32_t Atomic_Increment_u32 ( uint32_t volatile *  pAddend)
static

Atomic increment

Parameters
[in,out]pAddendPointer to memory location from where value is to be loaded and written back to.
Returns
*pAddend value before increment.

References ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE uint32_t Atomic_NAND_u32 ( uint32_t volatile *  pDestination,
uint32_t  ulValue 
)
static

Atomic NAND

Parameters
[in,out]pDestinationPointer to memory location from where value is to be loaded and written back to.
[in]ulValueValue to be NANDed with *pDestination.
Returns
The original value of *pDestination.

References ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE uint32_t Atomic_OR_u32 ( uint32_t volatile *  pDestination,
uint32_t  ulValue 
)
static

Atomic OR

Parameters
[in,out]pDestinationPointer to memory location from where value is to be loaded and written back to.
[in]ulValueValue to be ORed with *pDestination.
Returns
The original value of *pDestination.

References ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE uint32_t Atomic_Subtract_u32 ( uint32_t volatile *  pAddend,
uint32_t  ulCount 
)
static

Atomic subtract

Parameters
[in,out]pAddendPointer to memory location from where value is to be loaded and written back to.
[in]ulCountValue to be subtract from *pAddend.
Returns
previous *pAddend value.

References ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE void* Atomic_SwapPointers_p32 ( void *volatile *  ppDestination,
void *  pExchange 
)
static

Atomic swap (pointers)

Parameters
[in,out]ppDestinationPointer to memory location from where a pointer value is to be loaded and written back to.
[in]pExchangePointer value to be written to *ppDestination.
Returns
The initial value of *ppDestination.

References ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.

static portFORCE_INLINE uint32_t Atomic_XOR_u32 ( uint32_t volatile *  pDestination,
uint32_t  ulValue 
)
static

Atomic XOR

Parameters
[in,out]pDestinationPointer to memory location from where value is to be loaded and written back to.
[in]ulValueValue to be XORed with *pDestination.
Returns
The original value of *pDestination.

References ATOMIC_ENTER_CRITICAL, and ATOMIC_EXIT_CRITICAL.