STM32F7 Ethernet interface for nucleo STM32F767

Embed: (wiki syntax)

« Back to documentation index

critical section function

critical section function
[Platform]

Functions

bool core_util_are_interrupts_enabled (void)
 Determine the current interrupts enabled state.
bool core_util_is_isr_active (void)
 Determine if this code is executing from an interrupt.
void core_util_critical_section_enter (void)
 Mark the start of a critical section.
void core_util_critical_section_exit (void)
 Mark the end of a critical section.
bool core_util_atomic_cas_u8 (uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue)
 Atomic compare and set.
bool core_util_atomic_cas_u16 (uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue)
 Atomic compare and set.
bool core_util_atomic_cas_u32 (uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue)
 Atomic compare and set.
bool core_util_atomic_cas_ptr (void **ptr, void **expectedCurrentValue, void *desiredValue)
 Atomic compare and set.
uint8_t core_util_atomic_incr_u8 (uint8_t *valuePtr, uint8_t delta)
 Atomic increment.
uint16_t core_util_atomic_incr_u16 (uint16_t *valuePtr, uint16_t delta)
 Atomic increment.
uint32_t core_util_atomic_incr_u32 (uint32_t *valuePtr, uint32_t delta)
 Atomic increment.
void * core_util_atomic_incr_ptr (void **valuePtr, ptrdiff_t delta)
 Atomic increment.
uint8_t core_util_atomic_decr_u8 (uint8_t *valuePtr, uint8_t delta)
 Atomic decrement.
uint16_t core_util_atomic_decr_u16 (uint16_t *valuePtr, uint16_t delta)
 Atomic decrement.
uint32_t core_util_atomic_decr_u32 (uint32_t *valuePtr, uint32_t delta)
 Atomic decrement.
void * core_util_atomic_decr_ptr (void **valuePtr, ptrdiff_t delta)
 Atomic decrement.

Function Documentation

bool core_util_are_interrupts_enabled ( void   )

Determine the current interrupts enabled state.

This function can be called to determine whether or not interrupts are currently enabled.

Note:
NOTE: This function works for both cortex-A and cortex-M, although the underlyng implementation differs.
Returns:
true if interrupts are enabled, false otherwise

Definition at line 29 of file mbed_critical.c.

bool core_util_atomic_cas_ptr ( void **  ptr,
void **  expectedCurrentValue,
void *  desiredValue 
)

Atomic compare and set.

It compares the contents of a memory location to a given value and, only if they are the same, modifies the contents of that memory location to a given new value. This is done as a single atomic operation. The atomicity guarantees that the new value is calculated based on up-to-date information; if the value had been updated by another thread in the meantime, the write would fail due to a mismatched expectedCurrentValue.

Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect you to the article on compare-and swap].

Parameters:
ptrThe target memory location.
[in,out]expectedCurrentValueA pointer to some location holding the expected current value of the data being set atomically. The computed 'desiredValue' should be a function of this current value.
Note:
: This is an in-out parameter. In the failure case of atomic_cas (where the destination isn't set), the pointee of expectedCurrentValue is updated with the current value.
Parameters:
[in]desiredValueThe new value computed based on '*expectedCurrentValue'.
Returns:
true if the memory location was atomically updated with the desired value (after verifying that it contained the expectedCurrentValue), false otherwise. In the failure case, exepctedCurrentValue is updated with the new value of the target memory location.

pseudocode: function cas(p : pointer to int, old : pointer to int, new : int) returns bool { if *p != *old { *old = *p return false } *p = new return true }

Note:
: In the failure case (where the destination isn't set), the value pointed to by expectedCurrentValue is still updated with the current value. This property helps writing concise code for the following incr:

function incr(p : pointer to int, a : int) returns int { done = false value = *p // This fetch operation need not be atomic. while not done { done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success } return value + a }

Definition at line 322 of file mbed_critical.c.

bool core_util_atomic_cas_u16 ( uint16_t *  ptr,
uint16_t *  expectedCurrentValue,
uint16_t  desiredValue 
)

Atomic compare and set.

It compares the contents of a memory location to a given value and, only if they are the same, modifies the contents of that memory location to a given new value. This is done as a single atomic operation. The atomicity guarantees that the new value is calculated based on up-to-date information; if the value had been updated by another thread in the meantime, the write would fail due to a mismatched expectedCurrentValue.

Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect you to the article on compare-and swap].

Parameters:
ptrThe target memory location.
[in,out]expectedCurrentValueA pointer to some location holding the expected current value of the data being set atomically. The computed 'desiredValue' should be a function of this current value.
Note:
: This is an in-out parameter. In the failure case of atomic_cas (where the destination isn't set), the pointee of expectedCurrentValue is updated with the current value.
Parameters:
[in]desiredValueThe new value computed based on '*expectedCurrentValue'.
Returns:
true if the memory location was atomically updated with the desired value (after verifying that it contained the expectedCurrentValue), false otherwise. In the failure case, exepctedCurrentValue is updated with the new value of the target memory location.

pseudocode: function cas(p : pointer to int, old : pointer to int, new : int) returns bool { if *p != *old { *old = *p return false } *p = new return true }

Note:
: In the failure case (where the destination isn't set), the value pointed to by expectedCurrentValue is still updated with the current value. This property helps writing concise code for the following incr:

function incr(p : pointer to int, a : int) returns int { done = false value = *p // This fetch operation need not be atomic. while not done { done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success } return value + a }

Definition at line 123 of file mbed_critical.c.

bool core_util_atomic_cas_u32 ( uint32_t *  ptr,
uint32_t *  expectedCurrentValue,
uint32_t  desiredValue 
)

Atomic compare and set.

It compares the contents of a memory location to a given value and, only if they are the same, modifies the contents of that memory location to a given new value. This is done as a single atomic operation. The atomicity guarantees that the new value is calculated based on up-to-date information; if the value had been updated by another thread in the meantime, the write would fail due to a mismatched expectedCurrentValue.

Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect you to the article on compare-and swap].

Parameters:
ptrThe target memory location.
[in,out]expectedCurrentValueA pointer to some location holding the expected current value of the data being set atomically. The computed 'desiredValue' should be a function of this current value.
Note:
: This is an in-out parameter. In the failure case of atomic_cas (where the destination isn't set), the pointee of expectedCurrentValue is updated with the current value.
Parameters:
[in]desiredValueThe new value computed based on '*expectedCurrentValue'.
Returns:
true if the memory location was atomically updated with the desired value (after verifying that it contained the expectedCurrentValue), false otherwise. In the failure case, exepctedCurrentValue is updated with the new value of the target memory location.

pseudocode: function cas(p : pointer to int, old : pointer to int, new : int) returns bool { if *p != *old { *old = *p return false } *p = new return true }

Note:
: In the failure case (where the destination isn't set), the value pointed to by expectedCurrentValue is still updated with the current value. This property helps writing concise code for the following incr:

function incr(p : pointer to int, a : int) returns int { done = false value = *p // This fetch operation need not be atomic. while not done { done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success } return value + a }

Definition at line 136 of file mbed_critical.c.

bool core_util_atomic_cas_u8 ( uint8_t *  ptr,
uint8_t *  expectedCurrentValue,
uint8_t  desiredValue 
)

Atomic compare and set.

It compares the contents of a memory location to a given value and, only if they are the same, modifies the contents of that memory location to a given new value. This is done as a single atomic operation. The atomicity guarantees that the new value is calculated based on up-to-date information; if the value had been updated by another thread in the meantime, the write would fail due to a mismatched expectedCurrentValue.

Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect you to the article on compare-and swap].

Parameters:
ptrThe target memory location.
[in,out]expectedCurrentValueA pointer to some location holding the expected current value of the data being set atomically. The computed 'desiredValue' should be a function of this current value.
Note:
: This is an in-out parameter. In the failure case of atomic_cas (where the destination isn't set), the pointee of expectedCurrentValue is updated with the current value.
Parameters:
[in]desiredValueThe new value computed based on '*expectedCurrentValue'.
Returns:
true if the memory location was atomically updated with the desired value (after verifying that it contained the expectedCurrentValue), false otherwise. In the failure case, exepctedCurrentValue is updated with the new value of the target memory location.

pseudocode: function cas(p : pointer to int, old : pointer to int, new : int) returns bool { if *p != *old { *old = *p return false } *p = new return true }

Note:
: In the failure case (where the destination isn't set), the value pointed to by expectedCurrentValue is still updated with the current value. This property helps writing concise code for the following incr:

function incr(p : pointer to int, a : int) returns int { done = false value = *p // This fetch operation need not be atomic. while not done { done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success } return value + a }

Definition at line 111 of file mbed_critical.c.

void* core_util_atomic_decr_ptr ( void **  valuePtr,
ptrdiff_t  delta 
)

Atomic decrement.

Parameters:
valuePtrTarget memory location being decremented.
deltaThe amount being decremented in bytes.
Returns:
The new decremented value.
Note:
The type of the pointer argument is not taken into account and the pointer is decremented by bytes

Definition at line 333 of file mbed_critical.c.

uint16_t core_util_atomic_decr_u16 ( uint16_t *  valuePtr,
uint16_t  delta 
)

Atomic decrement.

Parameters:
valuePtrTarget memory location being decremented.
deltaThe amount being decremented.
Returns:
The new decremented value.

Definition at line 185 of file mbed_critical.c.

uint32_t core_util_atomic_decr_u32 ( uint32_t *  valuePtr,
uint32_t  delta 
)

Atomic decrement.

Parameters:
valuePtrTarget memory location being decremented.
deltaThe amount being decremented.
Returns:
The new decremented value.

Definition at line 194 of file mbed_critical.c.

uint8_t core_util_atomic_decr_u8 ( uint8_t *  valuePtr,
uint8_t  delta 
)

Atomic decrement.

Parameters:
valuePtrTarget memory location being decremented.
deltaThe amount being decremented.
Returns:
The new decremented value.

Definition at line 176 of file mbed_critical.c.

void* core_util_atomic_incr_ptr ( void **  valuePtr,
ptrdiff_t  delta 
)

Atomic increment.

Parameters:
valuePtrTarget memory location being incremented.
deltaThe amount being incremented in bytes.
Returns:
The new incremented value.
Note:
The type of the pointer argument is not taken into account and the pointer is incremented by bytes.

Definition at line 329 of file mbed_critical.c.

uint16_t core_util_atomic_incr_u16 ( uint16_t *  valuePtr,
uint16_t  delta 
)

Atomic increment.

Parameters:
valuePtrTarget memory location being incremented.
deltaThe amount being incremented.
Returns:
The new incremented value.

Definition at line 157 of file mbed_critical.c.

uint32_t core_util_atomic_incr_u32 ( uint32_t *  valuePtr,
uint32_t  delta 
)

Atomic increment.

Parameters:
valuePtrTarget memory location being incremented.
deltaThe amount being incremented.
Returns:
The new incremented value.

Definition at line 166 of file mbed_critical.c.

uint8_t core_util_atomic_incr_u8 ( uint8_t *  valuePtr,
uint8_t  delta 
)

Atomic increment.

Parameters:
valuePtrTarget memory location being incremented.
deltaThe amount being incremented.
Returns:
The new incremented value.

Definition at line 148 of file mbed_critical.c.

void core_util_critical_section_enter ( void   )

Mark the start of a critical section.

This function should be called to mark the start of a critical section of code.

Note:
NOTES: 1) The use of this style of critical section is targetted at C based implementations. 2) These critical sections can be nested. 3) The interrupt enable state on entry to the first critical section (of a nested set, or single section) will be preserved on exit from the section. 4) This implementation will currently only work on code running in privileged mode.

Definition at line 54 of file mbed_critical.c.

void core_util_critical_section_exit ( void   )

Mark the end of a critical section.

This function should be called to mark the end of a critical section of code.

Note:
NOTES: 1) The use of this style of critical section is targetted at C based implementations. 2) These critical sections can be nested. 3) The interrupt enable state on entry to the first critical section (of a nested set, or single section) will be preserved on exit from the section. 4) This implementation will currently only work on code running in privileged mode.

Definition at line 79 of file mbed_critical.c.

bool core_util_is_isr_active ( void   )

Determine if this code is executing from an interrupt.

This function can be called to determine if the code is running on interrupt context.

Note:
NOTE: This function works for both cortex-A and cortex-M, although the underlyng implementation differs.
Returns:
true if in an isr, false otherwise

Definition at line 38 of file mbed_critical.c.