From 70d345eda01eae7a378176337bb0ad5e887ea9c3 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Wed, 24 Oct 2018 10:24:13 -0700 Subject: [PATCH] VxWorks Update 1. Remove pthreads enable from VxWorks build. 2. Add mutex wrappers for native VxWorks mutex semaphores. --- wolfcrypt/src/wc_port.c | 41 ++++++++++++++++++++++++++++++++++++ wolfssl/wolfcrypt/settings.h | 1 - wolfssl/wolfcrypt/wc_port.h | 4 ++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index c5b8ddd95..75ffaf01b 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -753,6 +753,47 @@ int wolfSSL_CryptHwMutexUnLock(void) { return BAD_MUTEX_E; } +#elif defined(WOLFSSL_VXWORKS) + + int wc_InitMutex(wolfSSL_Mutex* m) + { + if (m) { + if ((*m = semMCreate(0)) != SEM_ID_NULL) + return 0; + } + return BAD_MUTEX_E; + } + + + int wc_FreeMutex(wolfSSL_Mutex* m) + { + if (m) { + if (semDelete(*m) == OK) + return 0; + } + return BAD_MUTEX_E; + } + + + int wc_LockMutex(wolfSSL_Mutex* m) + { + if (m) { + if (semTake(*m, WAIT_FOREVER) == OK) + return 0; + } + return BAD_MUTEX_E; + } + + + int wc_UnLockMutex(wolfSSL_Mutex* m) + { + if (m) { + if (semGive(*m) == OK) + return 0; + } + return BAD_MUTEX_E; + } + #elif defined(THREADX) int wc_InitMutex(wolfSSL_Mutex* m) diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 8ad27739f..7ef369de3 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -398,7 +398,6 @@ #ifdef VXWORKS_SIM #define TFM_NO_ASM #endif - #define WOLFSSL_PTHREADS #define WOLFSSL_HAVE_MIN #define WOLFSSL_HAVE_MAX #define USE_FAST_MATH diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index c612a24d9..25f30aeec 100755 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -74,6 +74,8 @@ /* do nothing */ #elif defined(FREESCALE_FREE_RTOS) #include "fsl_os_abstraction.h" +#elif defined(WOLFSSL_VXWORKS) + #include #elif defined(WOLFSSL_uITRON4) #include "stddef.h" #include "kernel.h" @@ -151,6 +153,8 @@ typedef MUTEX_STRUCT wolfSSL_Mutex; #elif defined(FREESCALE_FREE_RTOS) typedef mutex_t wolfSSL_Mutex; + #elif defined(WOLFSSL_VXWORKS) + typedef SEM_ID wolfSSL_Mutex; #elif defined(WOLFSSL_uITRON4) typedef struct wolfSSL_Mutex { T_CSEM sem ;