forked from wolfSSL/wolfssl
Freescale: Add KSDK Bare Metal build, TRNG support
This commit is contained in:
@@ -2497,6 +2497,15 @@ ProtocolVersion MakeDTLSv1_2(void)
|
|||||||
return (word32) mqxTime.SECONDS;
|
return (word32) mqxTime.SECONDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(FREESCALE_KSDK_BM)
|
||||||
|
|
||||||
|
#include "fsl_pit_driver.h"
|
||||||
|
|
||||||
|
word32 LowResTimer(void)
|
||||||
|
{
|
||||||
|
return PIT_DRV_GetUs();
|
||||||
|
}
|
||||||
|
|
||||||
#elif defined(WOLFSSL_TIRTOS)
|
#elif defined(WOLFSSL_TIRTOS)
|
||||||
|
|
||||||
word32 LowResTimer(void)
|
word32 LowResTimer(void)
|
||||||
|
@@ -113,6 +113,11 @@
|
|||||||
#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)
|
||||||
|
#include <time.h>
|
||||||
|
#define XTIME(t1) ksdk_time((t1))
|
||||||
|
#define XGMTIME(c, t) gmtime((c))
|
||||||
|
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
||||||
|
|
||||||
#elif defined(USER_TIME)
|
#elif defined(USER_TIME)
|
||||||
/* user time, and gmtime compatible functions, there is a gmtime
|
/* user time, and gmtime compatible functions, there is a gmtime
|
||||||
@@ -350,6 +355,27 @@ struct tm* mqx_gmtime(const time_t* clock, struct tm* tmpTime)
|
|||||||
|
|
||||||
#endif /* FREESCALE_MQX */
|
#endif /* FREESCALE_MQX */
|
||||||
|
|
||||||
|
#ifdef FREESCALE_KSDK_BM
|
||||||
|
|
||||||
|
/* setting for PIT timer */
|
||||||
|
#define PIT_INSTANCE 0
|
||||||
|
#define PIT_CHANNEL 0
|
||||||
|
|
||||||
|
#include "fsl_pit_driver.h"
|
||||||
|
|
||||||
|
time_t ksdk_time(time_t* timer)
|
||||||
|
{
|
||||||
|
time_t localTime;
|
||||||
|
|
||||||
|
if (timer == NULL)
|
||||||
|
timer = &localTime;
|
||||||
|
|
||||||
|
*timer = (PIT_DRV_ReadTimerUs(PIT_INSTANCE, PIT_CHANNEL)) / 1000000;
|
||||||
|
return *timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FREESCALE_KSDK_BM */
|
||||||
|
|
||||||
#ifdef WOLFSSL_TIRTOS
|
#ifdef WOLFSSL_TIRTOS
|
||||||
|
|
||||||
time_t XTIME(time_t * timer)
|
time_t XTIME(time_t * timer)
|
||||||
|
@@ -107,11 +107,15 @@ 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
|
||||||
#endif /* USE_WINDOWS_API */
|
#endif /* USE_WINDOWS_API */
|
||||||
|
|
||||||
#ifdef HAVE_INTEL_RDGEN
|
#ifdef HAVE_INTEL_RDGEN
|
||||||
static int wc_InitRng_IntelRD(void) ;
|
static int wc_InitRng_IntelRD(void) ;
|
||||||
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
|
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
|
||||||
@@ -1080,7 +1084,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
}
|
}
|
||||||
#endif /* WOLFSSL_MIC32MZ_RNG */
|
#endif /* WOLFSSL_MIC32MZ_RNG */
|
||||||
|
|
||||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) || \
|
||||||
|
defined(FREESCALE_KSDK_BM)
|
||||||
|
|
||||||
#ifdef FREESCALE_K70_RNGA
|
#ifdef FREESCALE_K70_RNGA
|
||||||
/*
|
/*
|
||||||
@@ -1154,6 +1159,14 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(FREESCALE_TRNG)
|
||||||
|
|
||||||
|
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||||
|
{
|
||||||
|
TRNG_DRV_GetRandomData(TRNG_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"
|
||||||
|
|
||||||
|
@@ -78,6 +78,9 @@
|
|||||||
/* Uncomment next line if building for Freescale KSDK MQX/RTCS/MFS */
|
/* Uncomment next line if building for Freescale KSDK MQX/RTCS/MFS */
|
||||||
/* #define FREESCALE_KSDK_MQX */
|
/* #define FREESCALE_KSDK_MQX */
|
||||||
|
|
||||||
|
/* Uncomment next line if building for Freescale KSDK Bare Metal */
|
||||||
|
/* #define FREESCALE_KSDK_BM */
|
||||||
|
|
||||||
/* Uncomment next line if using STM32F2 */
|
/* Uncomment next line if using STM32F2 */
|
||||||
/* #define WOLFSSL_STM32F2 */
|
/* #define WOLFSSL_STM32F2 */
|
||||||
|
|
||||||
@@ -461,15 +464,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FREESCALE_MQX
|
#ifdef FREESCALE_MQX
|
||||||
#define SIZEOF_LONG_LONG 8
|
#define FREESCALE_COMMON
|
||||||
#define NO_WRITEV
|
|
||||||
#define NO_DEV_RANDOM
|
|
||||||
#define NO_RABBIT
|
|
||||||
#define NO_WOLFSSL_DIR
|
|
||||||
#define USE_FAST_MATH
|
|
||||||
#define TFM_TIMING_RESISTANT
|
|
||||||
#define FREESCALE_K70_RNGA
|
|
||||||
/* #define FREESCALE_K53_RNGB */
|
|
||||||
#include "mqx.h"
|
#include "mqx.h"
|
||||||
#ifndef NO_FILESYSTEM
|
#ifndef NO_FILESYSTEM
|
||||||
#include "mfs.h"
|
#include "mfs.h"
|
||||||
@@ -485,16 +480,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FREESCALE_KSDK_MQX
|
#ifdef FREESCALE_KSDK_MQX
|
||||||
#define SIZEOF_LONG_LONG 8
|
#define FREESCALE_COMMON
|
||||||
#define NO_WRITEV
|
|
||||||
#define NO_DEV_RANDOM
|
|
||||||
#define NO_RABBIT
|
|
||||||
#define NO_WOLFSSL_DIR
|
|
||||||
#define USE_FAST_MATH
|
|
||||||
#define TFM_TIMING_RESISTANT
|
|
||||||
#define NO_OLD_RNGNAME
|
|
||||||
#define FREESCALE_K70_RNGA
|
|
||||||
/* #define FREESCALE_K53_RNGB */
|
|
||||||
#include <mqx.h>
|
#include <mqx.h>
|
||||||
#ifndef NO_FILESYSTEM
|
#ifndef NO_FILESYSTEM
|
||||||
#if MQX_USE_IO_OLD
|
#if MQX_USE_IO_OLD
|
||||||
@@ -513,6 +499,40 @@
|
|||||||
#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 */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef FREESCALE_KSDK_BM
|
||||||
|
#define FREESCALE_COMMON
|
||||||
|
#define WOLFSSL_USER_IO
|
||||||
|
#define SINGLE_THREADED
|
||||||
|
#define NO_FILESYSTEM
|
||||||
|
#define USE_WOLFSSL_MEMORY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FREESCALE_COMMON
|
||||||
|
#define SIZEOF_LONG_LONG 8
|
||||||
|
#define NO_WRITEV
|
||||||
|
#define NO_DEV_RANDOM
|
||||||
|
#define NO_RABBIT
|
||||||
|
#define NO_WOLFSSL_DIR
|
||||||
|
#define USE_FAST_MATH
|
||||||
|
#define TFM_TIMING_RESISTANT
|
||||||
|
|
||||||
|
#if FSL_FEATURE_SOC_ENET_COUNT == 0
|
||||||
|
#define WOLFSSL_USER_IO
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* random seed */
|
||||||
|
#define NO_OLD_RNGNAME
|
||||||
|
#if FSL_FEATURE_SOC_TRNG_COUNT > 0
|
||||||
|
#define FREESCALE_TRNG
|
||||||
|
#elif !defined(FREESCALE_KSDK_BM)
|
||||||
|
#define FREESCALE_K70_RNGA
|
||||||
|
/* #define FREESCALE_K53_RNGB */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* HW crypto */
|
||||||
|
/* #define FREESCALE_MMCAU */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_STM32F2
|
#ifdef WOLFSSL_STM32F2
|
||||||
#define SIZEOF_LONG_LONG 8
|
#define SIZEOF_LONG_LONG 8
|
||||||
#define NO_DEV_RANDOM
|
#define NO_DEV_RANDOM
|
||||||
|
Reference in New Issue
Block a user