|
CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
|
FreeRTOS semaphore compatibility layer. More...
Go to the source code of this file.
Classes | |
| struct | StaticSemaphore_t |
| Type used to define space for storing any of the exposed FreeRTOS semaphore types. More... | |
Macros | |
| #define | CHERIOT_FREERTOS_SEMAPHORE_CASE(x) |
| #define | CHERIOT_FREERTOS_MUTEX_CASE(x) |
| #define | CHERIOT_FREERTOS_RECURSIVE_MUTEX_CASE(x) |
| #define | CHERIOT_FREERTOS_SEMAPHORE_SWITCH(x) |
| #define | CHERIOT_FREERTOS_SEMAPHORE_KIND_SET(x, y) |
Typedefs | |
| typedef StaticSemaphore_t * | SemaphoreHandle_t |
| Type for a handle to a counting semaphore. | |
Enumerations | |
| enum | CheriotFreeRTOS_SemaphoreKind : uint8_t { CheriotFreeRTOS_Semaphore , CheriotFreeRTOS_Mutex , CheriotFreeRTOS_RecursiveMutex } |
| Enumeration used to differentiate the different kinds of FreeRTOS semaphores in this compatibility layer. More... | |
Functions | |
| static SemaphoreHandle_t | xSemaphoreCreateCountingStatic (UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer) |
| Initialise a statically allocated semaphore. | |
| static SemaphoreHandle_t | xSemaphoreCreateCounting (UBaseType_t uxMaxCount, UBaseType_t uxInitialCount) |
| Allocate a counting semaphore on the heap. | |
| static SemaphoreHandle_t | xSemaphoreCreateBinary () |
| Create a heap-allocated binary semaphore. | |
| static SemaphoreHandle_t | xSemaphoreCreateBinaryStatic (StaticSemaphore_t *pxSemaphoreBuffer) |
| Create a statically allocated binary semaphore. | |
| static SemaphoreHandle_t | xSemaphoreCreateMutexStatic (StaticSemaphore_t *pxMutexBuffer) |
| Create statically allocated mutex. | |
| static SemaphoreHandle_t | xSemaphoreCreateMutex () |
| Create a heap-allocated mutex. | |
| static SemaphoreHandle_t | xSemaphoreCreateRecursiveMutexStatic (StaticSemaphore_t *pxMutexBuffer) |
| Create a statically allocated recursive mutex. | |
| static SemaphoreHandle_t | xSemaphoreCreateRecursiveMutex (void) |
| Create a heap-allocated recursive mutex. | |
| static void | vSemaphoreDelete (SemaphoreHandle_t xSemaphore) |
| Delete a heap-allocated semaphore, of any kind. | |
| static TaskHandle_t | xSemaphoreGetMutexHolder (SemaphoreHandle_t xMutex) |
| Get the current owner (thread ID) of a mutex. | |
| static UBaseType_t | uxSemaphoreGetCount (SemaphoreHandle_t xSemaphore) |
| Returns the current count of a counting semaphore, or whether a mutex or binary semaphore is available. | |
| static _Bool | xSemaphoreTake (SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait) |
| A semaphore get (down) operation. | |
| static _Bool | xSemaphoreTakeFromISR (SemaphoreHandle_t xSemaphore, BaseType_t *pxHigherPriorityTaskWoken) |
| Take a semaphore from code that may run in an ISR. | |
| static _Bool | xSemaphoreTakeFromISR (SemaphoreHandle_t xSemaphore) |
| static _Bool | xSemaphoreGive (SemaphoreHandle_t xSemaphore) |
| A semaphore put (up) operation. | |
| static _Bool | xSemaphoreGiveFromISR (SemaphoreHandle_t xSemaphore, BaseType_t *pxHigherPriorityTaskWoken) |
| Give a semaphore from code that may run in an ISR. | |
| static _Bool | xSemaphoreGiveFromISR (SemaphoreHandle_t xSemaphore) |
| static _Bool | xSemaphoreTakeRecursive (SemaphoreHandle_t xMutex, TickType_t xTicksToWait) |
| Try to acquire a recursive mutex. | |
| static _Bool | xSemaphoreGiveRecursive (SemaphoreHandle_t xMutex) |
| Release a recursive mutex. | |
| static BaseType_t | xSemaphoreGetStaticBuffer (SemaphoreHandle_t xSemaphore, StaticSemaphore_t **ppxSemaphoreBuffer) |
| Launder a semaphore back into the type used to initialise it. | |
FreeRTOS semaphore compatibility layer.
This maps FreeRTOS semaphore types to their CHERIoT RTOS equivalents.
There is some overhead from dynamic dispatch that can be avoided if only one of the FreeRTOS semaphore types needs to be supported in a particular component. You can enable individual semaphore types by defining the following macros:
Definition in file semphr.h.
| #define CHERIOT_FREERTOS_MUTEX_CASE | ( | x | ) |
| #define CHERIOT_FREERTOS_RECURSIVE_MUTEX_CASE | ( | x | ) |
| #define CHERIOT_FREERTOS_SEMAPHORE_CASE | ( | x | ) |
| #define CHERIOT_FREERTOS_SEMAPHORE_KIND_SET | ( | x, | |
| y ) |
| #define CHERIOT_FREERTOS_SEMAPHORE_SWITCH | ( | x | ) |
| typedef StaticSemaphore_t* SemaphoreHandle_t |
| enum CheriotFreeRTOS_SemaphoreKind : uint8_t |
|
inlinestatic |
Returns the current count of a counting semaphore, or whether a mutex or binary semaphore is available.
Note: This API is inherently racy. Unless run with interrupts disabled, there is no guarantee that the value returned is still valid by the time the caller inspects it.
Definition at line 305 of file semphr.h.
References RecursiveMutexState::lock.
|
inlinestatic |
|
inlinestatic |
Create a heap-allocated binary semaphore.
Binary semaphores are implemented as counting semaphores with a maximum count of 1.
Definition at line 184 of file semphr.h.
References xSemaphoreCreateCounting().
|
inlinestatic |
Create a statically allocated binary semaphore.
Binary semaphores are implemented as counting semaphores with a maximum count of 1.
Definition at line 196 of file semphr.h.
References xSemaphoreCreateCountingStatic().
|
inlinestatic |
Allocate a counting semaphore on the heap.
The initial value and maximum are specified with uxInitialCount and uxMaxCount respectively.
Returns a pointer to the semaphore on success, NULL on allocation failure.
Definition at line 166 of file semphr.h.
References xSemaphoreCreateCountingStatic().
Referenced by xSemaphoreCreateBinary().
|
inlinestatic |
Initialise a statically allocated semaphore.
The initial value and maximum are specified with uxInitialCount and uxMaxCount respectively.
Returns a pointer to the semaphore.
Definition at line 142 of file semphr.h.
References CheriotFreeRTOS_Semaphore, and CountingSemaphoreState::maxCount.
Referenced by xSemaphoreCreateBinaryStatic(), and xSemaphoreCreateCounting().
|
inlinestatic |
Create a heap-allocated mutex.
Definition at line 218 of file semphr.h.
References xSemaphoreCreateMutexStatic().
|
inlinestatic |
Create statically allocated mutex.
Definition at line 207 of file semphr.h.
References CheriotFreeRTOS_Mutex.
Referenced by xSemaphoreCreateMutex().
|
inlinestatic |
Create a heap-allocated recursive mutex.
Definition at line 251 of file semphr.h.
References xSemaphoreCreateRecursiveMutexStatic().
|
inlinestatic |
Create a statically allocated recursive mutex.
Definition at line 237 of file semphr.h.
References CheriotFreeRTOS_RecursiveMutex, RecursiveMutexState::depth, and RecursiveMutexState::lock.
Referenced by xSemaphoreCreateRecursiveMutex().
|
inlinestatic |
Get the current owner (thread ID) of a mutex.
If this is a counting semaphore, or if the lock is not held, returns zero.
Note: This API is inherently somewhat racy. If this returns the current thread's thread ID, then it cannot change, but any other return value may change between the time it is returned and the time the caller inspects it.
Definition at line 285 of file semphr.h.
References RecursiveMutexState::lock.
|
inlinestatic |
|
inlinestatic |
A semaphore put (up) operation.
If there are tasks blocked on the semaphore, this will unblock one of them. Otherwise, the semaphore value is incremented by one.
Definition at line 372 of file semphr.h.
References flaglock_unlock(), and semaphore_put().
Referenced by xSemaphoreGiveFromISR().
|
inlinestatic |
|
inlinestatic |
Give a semaphore from code that may run in an ISR.
CHERIoT RTOS does not permit code to run in ISRs and so this simply calls the normal code paths.
The second parameter is a pointer to a variable that will be set to true if the caller needs to yield to wake a higher-priority task. This is unconditionally false on CHERIoT RTOS.
Definition at line 396 of file semphr.h.
References xSemaphoreGive(), and xSemaphoreGiveFromISR().
Referenced by xSemaphoreGiveFromISR().
|
inlinestatic |
Release a recursive mutex.
Definition at line 436 of file semphr.h.
References recursivemutex_unlock().
|
inlinestatic |
A semaphore get (down) operation.
If the semaphore value is zero, this can block for up to xTicksToWait ticks. Returns true if the semaphore was obtained, false if the timeout expired.
Definition at line 322 of file semphr.h.
References flaglock_priority_inheriting_trylock(), and semaphore_get().
Referenced by xSemaphoreTakeFromISR().
|
inlinestatic |
|
inlinestatic |
Take a semaphore from code that may run in an ISR.
CHERIoT RTOS does not permit code to run in ISRs and so this simply calls the normal code paths.
The second parameter is a pointer to a variable that will be set to true if the caller needs to yield to wake a higher-priority task. This is unconditionally false on CHERIoT RTOS because the scheduler will wake any threads that are waiting on a semaphore. It is necessary on FreeRTOS because code in ISRs cannot call into the scheduler.
Definition at line 350 of file semphr.h.
References xSemaphoreTake(), and xSemaphoreTakeFromISR().
Referenced by xSemaphoreTakeFromISR().
|
inlinestatic |
Try to acquire a recursive mutex.
Returns true on success, false on failure.
Definition at line 418 of file semphr.h.
References recursivemutex_trylock().