Detailed Description

Threading primitive implementation for mbed TLS.

This file contains the glue logic between the mbed TLS threading API and two RTOS'es supported, being Micrium OS and FreeRTOS. In order to enable support for Micrium OS the user must make sure SL_CATALOG_MICRIUMOS_KERNEL_PRESENT is defined. In order to enable support for FreeRTOS the user must make sure SL_CATALOG_FREERTOS_KERNEL_PRESENT is defined. For UC based applications the sl_component_catalog.h file should include one of the above in order to determine the presence of a specific RTOS. For non-UC based applications the application must explicitly define one of the above in order to specify the presence of a specific RTOS.

Note
In order to use the Silicon Labs Hardware Acceleration plugins in multi-threaded applications, select Mbed TLS support for EFM32/EFR32 crypto acceleration component.

Macros

#define SL_THREADING_ALT
 

Typedefs

typedef OS_MUTEX mbedtls_threading_mutex_t
 

Functions

static void THREADING_InitMutex (mbedtls_threading_mutex_t *mutex)
 Initialize a given mutex.
 
static void THREADING_FreeMutex (mbedtls_threading_mutex_t *mutex)
 Free a given mutex.
 
static int THREADING_TakeMutexBlocking (mbedtls_threading_mutex_t *mutex)
 Pend on a mutex.
 
static int THREADING_TakeMutexNonBlocking (mbedtls_threading_mutex_t *mutex)
 Try to own a mutex without waiting.
 
static int THREADING_GiveMutex (mbedtls_threading_mutex_t *mutex)
 Release a mutex.
 
void mbedtls_threading_set_alt (void(*mutex_init)(mbedtls_threading_mutex_t *), void(*mutex_free)(mbedtls_threading_mutex_t *), int(*mutex_lock)(mbedtls_threading_mutex_t *), int(*mutex_unlock)(mbedtls_threading_mutex_t *))
 
static void THREADING_setup (void)
 Helper function for setting up the mbed TLS threading subsystem.
 

Macro Definition Documentation

#define SL_THREADING_ALT

Definition at line 60 of file threading_alt.h.

Typedef Documentation

typedef OS_MUTEX mbedtls_threading_mutex_t

Definition at line 69 of file threading_alt.h.

Function Documentation

void mbedtls_threading_set_alt ( void(*)(mbedtls_threading_mutex_t *)  mutex_init,
void(*)(mbedtls_threading_mutex_t *)  mutex_free,
int(*)(mbedtls_threading_mutex_t *)  mutex_lock,
int(*)(mbedtls_threading_mutex_t *)  mutex_unlock 
)

Referenced by THREADING_setup().

static void THREADING_FreeMutex ( mbedtls_threading_mutex_t mutex)
inlinestatic

Free a given mutex.

Parameters
mutexPointer to the mutex being freed

Definition at line 88 of file threading_alt.h.

Referenced by THREADING_setup().

static int THREADING_GiveMutex ( mbedtls_threading_mutex_t mutex)
inlinestatic

Release a mutex.

Parameters
mutexPointer to the mutex being released
Returns
RTOS_ERR_NONE on success, error code otherwise.

Definition at line 139 of file threading_alt.h.

References MBEDTLS_ERR_THREADING_MUTEX_ERROR.

Referenced by THREADING_setup().

static void THREADING_InitMutex ( mbedtls_threading_mutex_t mutex)
inlinestatic

Initialize a given mutex.

Parameters
mutexPointer to the mutex needing initialization

Definition at line 76 of file threading_alt.h.

Referenced by THREADING_setup().

static void THREADING_setup ( void  )
inlinestatic

Helper function for setting up the mbed TLS threading subsystem.

Definition at line 230 of file threading_alt.h.

References mbedtls_threading_set_alt(), THREADING_FreeMutex(), THREADING_GiveMutex(), THREADING_InitMutex(), and THREADING_TakeMutexBlocking().

static int THREADING_TakeMutexBlocking ( mbedtls_threading_mutex_t mutex)
inlinestatic

Pend on a mutex.

Parameters
mutexPointer to the mutex being pended on
Returns
RTOS_ERR_NONE on success, error code otherwise.

Definition at line 102 of file threading_alt.h.

References MBEDTLS_ERR_THREADING_MUTEX_ERROR.

Referenced by THREADING_setup().

static int THREADING_TakeMutexNonBlocking ( mbedtls_threading_mutex_t mutex)
inlinestatic

Try to own a mutex without waiting.

Parameters
mutexPointer to the mutex being tested
Returns
RTOS_ERR_NONE on success (= mutex successfully owned), error code otherwise.

Definition at line 121 of file threading_alt.h.

References MBEDTLS_ERR_THREADING_MUTEX_ERROR.