forked from wolfSSL/wolfssl
FreeRTOS threads support, windows simulator support
This commit is contained in:
@@ -48,6 +48,9 @@
|
|||||||
/* Uncomment next line if using FreeRTOS */
|
/* Uncomment next line if using FreeRTOS */
|
||||||
/* #define FREERTOS */
|
/* #define FREERTOS */
|
||||||
|
|
||||||
|
/* Uncomment next line if using FreeRTOS Windows Simulator */
|
||||||
|
/* #define FREERTOS_WINSIM */
|
||||||
|
|
||||||
/* Uncomment next line if using lwip */
|
/* Uncomment next line if using lwip */
|
||||||
/* #define CYASSL_LWIP */
|
/* #define CYASSL_LWIP */
|
||||||
|
|
||||||
@@ -82,13 +85,22 @@
|
|||||||
#define NO_HC128
|
#define NO_HC128
|
||||||
#endif /* MBED */
|
#endif /* MBED */
|
||||||
|
|
||||||
|
#ifdef FREERTOS_WINSIM
|
||||||
|
#define FREERTOS
|
||||||
|
#define USE_WINDOWS_API
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FREERTOS
|
#ifdef FREERTOS
|
||||||
#define SINGLE_THREADED
|
|
||||||
#define NO_WRITEV
|
#define NO_WRITEV
|
||||||
#define NO_SHA512
|
#define NO_SHA512
|
||||||
#define NO_DH
|
#define NO_DH
|
||||||
#define NO_DSA
|
#define NO_DSA
|
||||||
#define NO_HC128
|
#define NO_HC128
|
||||||
|
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "semphr.h"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CYASSL_GAME_BUILD
|
#ifdef CYASSL_GAME_BUILD
|
||||||
|
@@ -132,7 +132,7 @@ enum {
|
|||||||
|
|
||||||
|
|
||||||
/* Micrium will use Visual Studio for compilation but not the Win32 API */
|
/* Micrium will use Visual Studio for compilation but not the Win32 API */
|
||||||
#if defined(_WIN32) && !defined(MICRIUM)
|
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS)
|
||||||
#define USE_WINDOWS_API
|
#define USE_WINDOWS_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -69,6 +69,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#elif defined(MICRIUM)
|
#elif defined(MICRIUM)
|
||||||
/* do nothing, just don't pick Unix */
|
/* do nothing, just don't pick Unix */
|
||||||
|
#elif defined(FREERTOS)
|
||||||
|
/* do nothing */
|
||||||
#else
|
#else
|
||||||
#ifndef SINGLE_THREADED
|
#ifndef SINGLE_THREADED
|
||||||
#define CYASSL_PTHREADS
|
#define CYASSL_PTHREADS
|
||||||
@@ -662,7 +664,10 @@ struct CYASSL_CIPHER {
|
|||||||
#ifdef SINGLE_THREADED
|
#ifdef SINGLE_THREADED
|
||||||
typedef int CyaSSL_Mutex;
|
typedef int CyaSSL_Mutex;
|
||||||
#else /* MULTI_THREADED */
|
#else /* MULTI_THREADED */
|
||||||
#ifdef USE_WINDOWS_API
|
/* FREERTOS comes first to enable use of FreeRTOS Windows simulator only */
|
||||||
|
#ifdef FREERTOS
|
||||||
|
typedef xSemaphoreHandle CyaSSL_Mutex;
|
||||||
|
#elif defined(USE_WINDOWS_API)
|
||||||
typedef CRITICAL_SECTION CyaSSL_Mutex;
|
typedef CRITICAL_SECTION CyaSSL_Mutex;
|
||||||
#elif defined(CYASSL_PTHREADS)
|
#elif defined(CYASSL_PTHREADS)
|
||||||
typedef pthread_mutex_t CyaSSL_Mutex;
|
typedef pthread_mutex_t CyaSSL_Mutex;
|
||||||
|
@@ -6860,7 +6860,41 @@ int UnLockMutex(CyaSSL_Mutex* m)
|
|||||||
|
|
||||||
#else /* MULTI_THREAD */
|
#else /* MULTI_THREAD */
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_API
|
#if defined(FREERTOS)
|
||||||
|
|
||||||
|
int InitMutex(CyaSSL_Mutex* m)
|
||||||
|
{
|
||||||
|
int iReturn;
|
||||||
|
|
||||||
|
*m = ( CyaSSL_Mutex ) xSemaphoreCreateMutex();
|
||||||
|
if( *m != NULL )
|
||||||
|
iReturn = 0;
|
||||||
|
else
|
||||||
|
iReturn = BAD_MUTEX_ERROR;
|
||||||
|
|
||||||
|
return iReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FreeMutex(CyaSSL_Mutex* m)
|
||||||
|
{
|
||||||
|
vSemaphoreDelete( *m );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LockMutex(CyaSSL_Mutex* m)
|
||||||
|
{
|
||||||
|
/* Assume an infinite block, or should there be zero block? */
|
||||||
|
xSemaphoreTake( *m, portMAX_DELAY );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int UnLockMutex(CyaSSL_Mutex* m)
|
||||||
|
{
|
||||||
|
xSemaphoreGive( *m );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(USE_WINDOWS_API)
|
||||||
|
|
||||||
int InitMutex(CyaSSL_Mutex* m)
|
int InitMutex(CyaSSL_Mutex* m)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user