OR1K support
 All Functions Typedefs Groups
Functions
Multicore and Synchronization Support

Functions

uint32_t or1k_coreid (void)
 
uint32_t or1k_numcores (void)
 
uint32_t or1k_sync_ll (void *address)
 
int or1k_sync_sc (void *address, uint32_t value)
 
uint32_t or1k_sync_cas (void *address, uint32_t compare, uint32_t swap)
 
int or1k_sync_tsl (void *address)
 

Detailed Description

Function Documentation

uint32_t or1k_coreid ( void  )

Read core identifier

Returns
Core identifier
uint32_t or1k_numcores ( void  )

Read number of cores

Returns
Total number of cores
uint32_t or1k_sync_cas ( void *  address,
uint32_t  compare,
uint32_t  swap 
)

Compare and Swap

Loads a data item from the memory and compares a given value to it. If the values match, a new value is written to the memory, if they mismatch, the operation is aborted. The whole operation is atomic, i.e., it is guaranteed that no other core changes the value between the read and the write.

Parameters
addressAddress to operate on
compareCompare value
swapNew value to write
Returns
The value read from memory (can be used to check for success)
uint32_t or1k_sync_ll ( void *  address)

Load linked

Load a value from the given address and link it. If the following or1k_sync_sc() goes to the same address and there was no conflicting access between loading and storing, the value is written back, else the write fails.

Parameters
addressAddress to load value from
Returns
Value read from the address
int or1k_sync_sc ( void *  address,
uint32_t  value 
)

Store conditional

Conditionally store a value to the address. The address must have been read before using or1k_sync_ll() and there must be no other load link after that, otherwise this will always fail. In case there was no other write to the same address in between the load link and the store conditional, the store is successful, otherwise it will also fail.

Parameters
addressAddress to conditionally store to
valueValue to write to address
Returns
1 if success, 0 if fail
int or1k_sync_tsl ( void *  address)

Test and Set Lock

Check for a lock on an address. This means, if there is 0 at an address it will overwrite it with one and return 0. If the lock was already set (value 1 read from address), the function returns 1. The operation is atomic.

Parameters
addressAddress of the lock
Returns
0 if success, 1 if failed