Threading PrimitivesCryptography Hardware Acceleration Plugins

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.

Note
In order to use the Silicon Labs Hardware Acceleration plugins in multi-threaded applications, define MBEDTLS_THREADING_C in your build setup and call THREADING_setup() after the RTOS is initialized and before before calling any mbed TLS function.

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 48 of file threading_alt.h.

Typedef Documentation

typedef OS_MUTEX mbedtls_threading_mutex_t

Definition at line 57 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 76 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 127 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 64 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 218 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 90 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 109 of file threading_alt.h.

References MBEDTLS_ERR_THREADING_MUTEX_ERROR.