mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
Merge pull request #272 from cconlon/ksdk-fixes
Update support for Freescale KSDK 1.3.0, fix Freescale+FreeRTOS build
This commit is contained in:
@@ -2816,7 +2816,7 @@ ProtocolVersion MakeDTLSv1_2(void)
|
|||||||
return (word32) mqxTime.SECONDS;
|
return (word32) mqxTime.SECONDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(FREESCALE_KSDK_BM)
|
#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
||||||
|
|
||||||
#include "fsl_pit_driver.h"
|
#include "fsl_pit_driver.h"
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
#include <wolfssl/internal.h>
|
#include <wolfssl/internal.h>
|
||||||
#include <wolfssl/error-ssl.h>
|
#include <wolfssl/error-ssl.h>
|
||||||
#if defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST)
|
#if defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST)
|
||||||
#ifdef FREESCALE_MQX
|
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
#if MQX_USE_IO_OLD
|
#if MQX_USE_IO_OLD
|
||||||
#include <fio.h>
|
#include <fio.h>
|
||||||
#else
|
#else
|
||||||
|
@@ -117,7 +117,7 @@
|
|||||||
#define XTIME(t1) mqx_time((t1))
|
#define XTIME(t1) mqx_time((t1))
|
||||||
#define XGMTIME(c, t) mqx_gmtime((c), (t))
|
#define XGMTIME(c, t) mqx_gmtime((c), (t))
|
||||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
||||||
#elif defined(FREESCALE_KSDK_BM)
|
#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#define XTIME(t1) ksdk_time((t1))
|
#define XTIME(t1) ksdk_time((t1))
|
||||||
#define XGMTIME(c, t) gmtime((c))
|
#define XGMTIME(c, t) gmtime((c))
|
||||||
@@ -373,11 +373,7 @@ struct tm* mqx_gmtime(const time_t* clock, struct tm* tmpTime)
|
|||||||
|
|
||||||
#endif /* FREESCALE_MQX */
|
#endif /* FREESCALE_MQX */
|
||||||
|
|
||||||
#ifdef FREESCALE_KSDK_BM
|
#if defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
||||||
|
|
||||||
/* setting for PIT timer */
|
|
||||||
#define PIT_INSTANCE 0
|
|
||||||
#define PIT_CHANNEL 0
|
|
||||||
|
|
||||||
#include "fsl_pit_driver.h"
|
#include "fsl_pit_driver.h"
|
||||||
|
|
||||||
@@ -3010,7 +3006,8 @@ int ValidateDate(const byte* date, byte format, int dateType)
|
|||||||
int diffHH = 0 ; int diffMM = 0 ;
|
int diffHH = 0 ; int diffMM = 0 ;
|
||||||
int diffSign = 0 ;
|
int diffSign = 0 ;
|
||||||
|
|
||||||
#if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME)
|
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) || \
|
||||||
|
defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME)
|
||||||
struct tm tmpTimeStorage;
|
struct tm tmpTimeStorage;
|
||||||
tmpTime = &tmpTimeStorage;
|
tmpTime = &tmpTimeStorage;
|
||||||
#else
|
#else
|
||||||
@@ -5999,7 +5996,7 @@ static int CopyValidity(byte* output, Cert* cert)
|
|||||||
/* for systems where mktime() doesn't normalize fully */
|
/* for systems where mktime() doesn't normalize fully */
|
||||||
static void RebuildTime(time_t* in, struct tm* out)
|
static void RebuildTime(time_t* in, struct tm* out)
|
||||||
{
|
{
|
||||||
#ifdef FREESCALE_MQX
|
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
out = localtime_r(in, out);
|
out = localtime_r(in, out);
|
||||||
#else
|
#else
|
||||||
(void)in;
|
(void)in;
|
||||||
@@ -6025,7 +6022,8 @@ static int SetValidity(byte* output, int daysValid)
|
|||||||
struct tm* tmpTime = NULL;
|
struct tm* tmpTime = NULL;
|
||||||
struct tm local;
|
struct tm local;
|
||||||
|
|
||||||
#if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME)
|
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) || \
|
||||||
|
defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME)
|
||||||
/* for use with gmtime_r */
|
/* for use with gmtime_r */
|
||||||
struct tm tmpTimeStorage;
|
struct tm tmpTimeStorage;
|
||||||
tmpTime = &tmpTimeStorage;
|
tmpTime = &tmpTimeStorage;
|
||||||
|
@@ -46,7 +46,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SHOW_GEN
|
#ifdef SHOW_GEN
|
||||||
#ifdef FREESCALE_MQX
|
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
#if MQX_USE_IO_OLD
|
#if MQX_USE_IO_OLD
|
||||||
#include <fio.h>
|
#include <fio.h>
|
||||||
#else
|
#else
|
||||||
|
@@ -89,7 +89,7 @@ void wolfSSL_Debugging_OFF(void)
|
|||||||
|
|
||||||
#ifdef DEBUG_WOLFSSL
|
#ifdef DEBUG_WOLFSSL
|
||||||
|
|
||||||
#ifdef FREESCALE_MQX
|
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
#if MQX_USE_IO_OLD
|
#if MQX_USE_IO_OLD
|
||||||
#include <fio.h>
|
#include <fio.h>
|
||||||
#else
|
#else
|
||||||
|
@@ -114,10 +114,6 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
|
|||||||
#ifndef EBSNET
|
#ifndef EBSNET
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#elif defined(FREESCALE_TRNG)
|
|
||||||
#define TRNG_INSTANCE (0)
|
|
||||||
#include "fsl_device_registers.h"
|
|
||||||
#include "fsl_trng_driver.h"
|
|
||||||
#else
|
#else
|
||||||
/* include headers that may be needed to get good seed */
|
/* include headers that may be needed to get good seed */
|
||||||
#endif
|
#endif
|
||||||
@@ -1188,6 +1184,15 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(FREESCALE_RNGA)
|
||||||
|
|
||||||
|
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||||
|
{
|
||||||
|
RNGA_DRV_GetRandomData(RNGA_INSTANCE, output, sz);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#warning "write a real random seed!!!!, just for testing now"
|
#warning "write a real random seed!!!!, just for testing now"
|
||||||
|
|
||||||
|
@@ -138,7 +138,8 @@ int UnLockMutex(wolfSSL_Mutex *m)
|
|||||||
|
|
||||||
#else /* MULTI_THREAD */
|
#else /* MULTI_THREAD */
|
||||||
|
|
||||||
#if defined(FREERTOS) || defined(FREERTOS_TCP)
|
#if defined(FREERTOS) || defined(FREERTOS_TCP) || \
|
||||||
|
defined(FREESCALE_FREE_RTOS)
|
||||||
|
|
||||||
int InitMutex(wolfSSL_Mutex* m)
|
int InitMutex(wolfSSL_Mutex* m)
|
||||||
{
|
{
|
||||||
@@ -390,7 +391,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(FREESCALE_MQX)
|
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
|
|
||||||
int InitMutex(wolfSSL_Mutex* m)
|
int InitMutex(wolfSSL_Mutex* m)
|
||||||
{
|
{
|
||||||
|
@@ -119,7 +119,7 @@
|
|||||||
#include "cavium_ioctl.h"
|
#include "cavium_ioctl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FREESCALE_MQX
|
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
#include <mqx.h>
|
#include <mqx.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if MQX_USE_IO_OLD
|
#if MQX_USE_IO_OLD
|
||||||
|
@@ -121,6 +121,8 @@
|
|||||||
/* do nothing */
|
/* do nothing */
|
||||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
|
#elif defined(FREESCALE_FREE_RTOS)
|
||||||
|
#include "fsl_os_abstraction.h"
|
||||||
#elif defined(WOLFSSL_uITRON4)
|
#elif defined(WOLFSSL_uITRON4)
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
#elif defined(WOLFSSL_uTKERNEL2)
|
#elif defined(WOLFSSL_uTKERNEL2)
|
||||||
|
@@ -610,6 +610,10 @@ static char *fgets(char *buff, int sz, FILE *fp)
|
|||||||
#define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
|
#define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
|
||||||
#define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
|
#define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
|
||||||
#define XREALLOC(p, n, h, t) _mem_realloc((p), (n)) /* since MQX 4.1.2 */
|
#define XREALLOC(p, n, h, t) _mem_realloc((p), (n)) /* since MQX 4.1.2 */
|
||||||
|
|
||||||
|
#define MQX_FILE_PTR FILE *
|
||||||
|
#define IO_SEEK_SET SEEK_SET
|
||||||
|
#define IO_SEEK_END SEEK_END
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FREESCALE_KSDK_BM
|
#ifdef FREESCALE_KSDK_BM
|
||||||
@@ -624,9 +628,8 @@ static char *fgets(char *buff, int sz, FILE *fp)
|
|||||||
#define FREESCALE_COMMON
|
#define FREESCALE_COMMON
|
||||||
#define NO_FILESYSTEM
|
#define NO_FILESYSTEM
|
||||||
#define NO_MAIN_DRIVER
|
#define NO_MAIN_DRIVER
|
||||||
#define XMALLOC(s, h, t) OSA_MemAlloc(s);
|
#define XMALLOC(s, h, t) OSA_MemAlloc(s);(void)h;(void)t;
|
||||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) OSA_MemFree((xp));}
|
#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
|
#ifdef FREESCALE_KSDK_BM
|
||||||
#error Baremetal and FreeRTOS cannot be both enabled at the same time!
|
#error Baremetal and FreeRTOS cannot be both enabled at the same time!
|
||||||
#endif
|
#endif
|
||||||
@@ -638,24 +641,46 @@ static char *fgets(char *buff, int sz, FILE *fp)
|
|||||||
|
|
||||||
#ifdef FREESCALE_COMMON
|
#ifdef FREESCALE_COMMON
|
||||||
#define SIZEOF_LONG_LONG 8
|
#define SIZEOF_LONG_LONG 8
|
||||||
|
|
||||||
|
/* disable features */
|
||||||
#define NO_WRITEV
|
#define NO_WRITEV
|
||||||
#define NO_DEV_RANDOM
|
#define NO_DEV_RANDOM
|
||||||
#define NO_RABBIT
|
#define NO_RABBIT
|
||||||
#define NO_WOLFSSL_DIR
|
#define NO_WOLFSSL_DIR
|
||||||
|
|
||||||
|
/* enable features */
|
||||||
#define USE_FAST_MATH
|
#define USE_FAST_MATH
|
||||||
|
|
||||||
|
/* memory reduction */
|
||||||
#define TFM_TIMING_RESISTANT
|
#define TFM_TIMING_RESISTANT
|
||||||
|
|
||||||
#if FSL_FEATURE_SOC_ENET_COUNT == 0
|
/* setting for PIT timer */
|
||||||
#define WOLFSSL_USER_IO
|
#define PIT_INSTANCE 0
|
||||||
|
#define PIT_CHANNEL 0
|
||||||
|
|
||||||
|
/* CW GCC workaround. gmtime() is not available */
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define USER_TIME
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FREESCALE_KSDK_MQX) || defined(FREESCALE_KSDK_BM) || \
|
||||||
|
defined(FREESCALE_FREE_RTOS)
|
||||||
|
#include "fsl_device_registers.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* random seed */
|
/* random seed */
|
||||||
#define NO_OLD_RNGNAME
|
#define NO_OLD_RNGNAME
|
||||||
#if FSL_FEATURE_SOC_TRNG_COUNT > 0
|
#if (FSL_FEATURE_SOC_TRNG_COUNT > 0)
|
||||||
#define FREESCALE_TRNG
|
#define FREESCALE_TRNG
|
||||||
|
#define TRNG_INSTANCE (0)
|
||||||
|
#elif (FSL_FEATURE_SOC_RNG_COUNT > 0)
|
||||||
|
#include "fsl_rnga_driver.h"
|
||||||
|
#define FREESCALE_RNGA
|
||||||
|
#define RNGA_INSTANCE (0)
|
||||||
#elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS)
|
#elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS)
|
||||||
#define FREESCALE_K70_RNGA
|
/* defaulting to K70 RNGA, user should change if different */
|
||||||
/* #define FREESCALE_K53_RNGB */
|
/* #define FREESCALE_K53_RNGB */
|
||||||
|
#define FREESCALE_K70_RNGA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* HW crypto */
|
/* HW crypto */
|
||||||
|
@@ -198,7 +198,7 @@ WOLFSSL_API int wolfCrypt_Init(void);
|
|||||||
#define XFCLOSE fs_close
|
#define XFCLOSE fs_close
|
||||||
#define XSEEK_END 0
|
#define XSEEK_END 0
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#elif defined(FREESCALE_MQX)
|
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
#define XFILE MQX_FILE_PTR
|
#define XFILE MQX_FILE_PTR
|
||||||
#define XFOPEN fopen
|
#define XFOPEN fopen
|
||||||
#define XFSEEK fseek
|
#define XFSEEK fseek
|
||||||
|
Reference in New Issue
Block a user