From be5ac590b78ea6a849fdd90ce32daae16ff94e0a Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Tue, 1 Sep 2015 15:37:11 -0600 Subject: [PATCH] Freescale: Add KSDK FreeRTOS build, using fastmath --- wolfcrypt/src/random.c | 2 +- wolfssl/wolfcrypt/settings.h | 21 ++++++++++++++++++++- wolfssl/wolfcrypt/types.h | 6 +++--- wolfssl/wolfcrypt/wc_port.h | 4 ++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index e31912694..53aa093c7 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -1085,7 +1085,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) #endif /* WOLFSSL_MIC32MZ_RNG */ #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) || \ - defined(FREESCALE_KSDK_BM) + defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS) #ifdef FREESCALE_K70_RNGA /* diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index cf1465bb5..5a8ce7b01 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -81,6 +81,9 @@ /* Uncomment next line if building for Freescale KSDK Bare Metal */ /* #define FREESCALE_KSDK_BM */ +/* Uncomment next line if building for Freescale FreeRTOS */ +/* #define FREESCALE_FREE_RTOS */ + /* Uncomment next line if using STM32F2 */ /* #define WOLFSSL_STM32F2 */ @@ -555,6 +558,22 @@ static char *fgets(char *buff, int sz, FILE *fp) #define USE_WOLFSSL_MEMORY #endif +#ifdef FREESCALE_FREE_RTOS + #define FREESCALE_COMMON + #define NO_FILESYSTEM + #define NO_MAIN_DRIVER + #define XMALLOC(s, h, t) OSA_MemAlloc(s); + #define XFREE(p, h, t) {void* xp = (p); if((xp)) OSA_MemFree((xp));} + #define XREALLOC(p, n, h, t) ksdk_realloc((p), (n), (h), (t)); + #ifdef FREESCALE_KSDK_BM + #error Baremetal and FreeRTOS cannot be both enabled at the same time! + #endif + #ifndef SINGLE_THREADED + #include "FreeRTOS.h" + #include "semphr.h" + #endif +#endif + #ifdef FREESCALE_COMMON #define SIZEOF_LONG_LONG 8 #define NO_WRITEV @@ -572,7 +591,7 @@ static char *fgets(char *buff, int sz, FILE *fp) #define NO_OLD_RNGNAME #if FSL_FEATURE_SOC_TRNG_COUNT > 0 #define FREESCALE_TRNG - #elif !defined(FREESCALE_KSDK_BM) + #elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS) #define FREESCALE_K70_RNGA /* #define FREESCALE_K53_RNGB */ #endif diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index 2865f01aa..324c8d1b1 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -179,9 +179,9 @@ #define XREALLOC(p, n, h, t) realloc((p), (n)) #elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \ && !defined(WOLFSSL_SAFERTOS) && !defined(FREESCALE_MQX) \ - && !defined(FREESCALE_KSDK_MQX) && !defined(WOLFSSL_LEANPSK) \ - && !defined(FREERTOS) && !defined(WOLFSSL_uITRON4) \ - && !defined(WOLFSSL_uTKERNEL2) + && !defined(FREESCALE_KSDK_MQX) && !defined(FREESCALE_FREE_RTOS) \ + && !defined(WOLFSSL_LEANPSK) && !defined(FREERTOS) \ + && !defined(WOLFSSL_uITRON4) && !defined(WOLFSSL_uTKERNEL2) /* default C runtime, can install different routines at runtime via cbs */ #include #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s))) diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 04155360b..2056b7cde 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -55,6 +55,8 @@ /* do nothing */ #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) /* do nothing */ +#elif defined(FREESCALE_FREE_RTOS) + #include "fsl_os_abstraction.h" #elif defined(WOLFSSL_uITRON4) #include "kernel.h" #elif defined(WOLFSSL_uTKERNEL2) @@ -104,6 +106,8 @@ typedef RTP_MUTEX wolfSSL_Mutex; #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) typedef MUTEX_STRUCT wolfSSL_Mutex; + #elif defined(FREESCALE_FREE_RTOS) + typedef mutex_t wolfSSL_Mutex; #elif defined(WOLFSSL_uITRON4) typedef struct wolfSSL_Mutex { T_CSEM sem ;