[修改] 增加freeRTOS
1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
167
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/LPC43xx/time-LCP43xx.c
vendored
Normal file
167
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/LPC43xx/time-LCP43xx.c
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
/* time.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* initialize RTC
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include "lpc43xx_rtc.h"
|
||||
#include "lpc43xx_cgu.h"
|
||||
|
||||
static void init_RTC()
|
||||
{
|
||||
/* Enable GPIO register interface clock */
|
||||
LPC_CCU1->CLK_M4_GPIO_CFG |= 1;
|
||||
while (!(LPC_CCU1->CLK_M4_GPIO_STAT & 1)) ;
|
||||
|
||||
/* RTC Block section ------------------------------------------------------ */
|
||||
/* Init RTC module */
|
||||
RTC_Init(LPC_RTC);
|
||||
|
||||
/* Set ALARM time for second */
|
||||
RTC_SetAlarmTime (LPC_RTC, RTC_TIMETYPE_SECOND, 30);
|
||||
|
||||
/* Set the AMR for 30s match alarm interrupt */
|
||||
RTC_AlarmIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);
|
||||
|
||||
/* Set the CIIR for minute counter interrupt*/
|
||||
RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_MINUTE, ENABLE);
|
||||
|
||||
/* Enable rtc (starts increase the tick counter and second counter register) */
|
||||
RTC_Cmd(LPC_RTC, ENABLE);
|
||||
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* initialize TIM
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "lpc43xx_timer.h"
|
||||
|
||||
static void init_TIM()
|
||||
{
|
||||
TIM_TIMERCFG_Type TIM_ConfigStruct;
|
||||
/* Initialize timer 0, prescale count time of 1uS */
|
||||
TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_TICKVAL;
|
||||
TIM_ConfigStruct.PrescaleValue = 204; /* 204MHz */
|
||||
/* Set configuration for Tim_config and Tim_MatchConfig */
|
||||
TIM_Init(LPC_TIMER2, TIM_TIMER_MODE,&TIM_ConfigStruct);
|
||||
TIM_ResetCounter(LPC_TIMER2);
|
||||
/* To start timer 2 */
|
||||
TIM_Cmd(LPC_TIMER2,ENABLE);
|
||||
}
|
||||
|
||||
double current_time()
|
||||
{
|
||||
return (double)LPC_TIMER2->TC/1000000.0;
|
||||
}
|
||||
|
||||
|
||||
void init_time(void) {
|
||||
init_RTC() ;
|
||||
init_TIM() ;
|
||||
}
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct tm *Cyassl_MDK_gmtime(const time_t *c)
|
||||
{
|
||||
static struct tm date ;
|
||||
|
||||
RTC_TIME_Type RTCFullTime;
|
||||
RTC_GetFullTime (LPC_RTC, &RTCFullTime);
|
||||
|
||||
date.tm_year = RTCFullTime.YEAR + 100 ;
|
||||
date.tm_mon = RTCFullTime.MONTH - 1 ;
|
||||
date.tm_mday = RTCFullTime.DOM ;
|
||||
date.tm_hour = RTCFullTime.HOUR ;
|
||||
date.tm_min = RTCFullTime.MIN ;
|
||||
date.tm_sec = RTCFullTime.SEC ;
|
||||
|
||||
#if defined(DEBUG_CYASSL)
|
||||
{
|
||||
extern void CYASSL_MSG(char *msg) ;
|
||||
char msg[100] ;
|
||||
sprintf(msg, "Debug::Cyassl_KEIL_gmtime(DATE=/%4d/%02d/%02d TIME=%02d:%02d:%02d)\n",
|
||||
RTCFullTime.YEAR+2000, RTCFullTime.MONTH, RTCFullTime.DOM,
|
||||
RTCFullTime.HOUR, RTCFullTime.MIN, RTCFullTime.SEC) ;
|
||||
CYASSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
return(&date) ;
|
||||
}
|
||||
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void time_main(void *args)
|
||||
{
|
||||
char * datetime ;
|
||||
int year ;
|
||||
RTC_TIME_Type RTCFullTime;
|
||||
|
||||
if( args == NULL || ((func_args *)args)->argc == 1) {
|
||||
RTC_GetFullTime (LPC_RTC, &RTCFullTime);
|
||||
printf("Date: %d/%d/%d, Time: %02d:%02d:%02d\n",
|
||||
RTCFullTime.MONTH, RTCFullTime.DOM, RTCFullTime.YEAR+2000,
|
||||
RTCFullTime.HOUR, RTCFullTime.MIN, RTCFullTime.SEC) ;
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-' &&
|
||||
((func_args *)args)->argv[1][1] == 'd' ) {
|
||||
|
||||
datetime = ((func_args *)args)->argv[2];
|
||||
sscanf(datetime, "%d/%d/%d",
|
||||
(int *)&RTCFullTime.MONTH, (int *)&RTCFullTime.DOM, &year) ;
|
||||
RTCFullTime.YEAR = year - 2000 ;
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MONTH, RTCFullTime.MONTH);
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_YEAR, RTCFullTime.YEAR);
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_DAYOFMONTH, RTCFullTime.DOM);
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-' &&
|
||||
((func_args *)args)->argv[1][1] == 't' ) {
|
||||
RTC_GetFullTime (LPC_RTC, &RTCFullTime);
|
||||
datetime = ((func_args *)args)->argv[2];
|
||||
sscanf(datetime, "%d:%d:%d",
|
||||
(int *)&RTCFullTime.HOUR,
|
||||
(int *)&RTCFullTime.MIN,
|
||||
(int *)&RTCFullTime.SEC
|
||||
) ;
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, RTCFullTime.SEC);
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MINUTE, RTCFullTime.MIN);
|
||||
RTC_SetTime (LPC_RTC, RTC_TIMETYPE_HOUR, RTCFullTime.HOUR);
|
||||
} else printf("Invalid argument\n") ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
263
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/Retarget.c
vendored
Normal file
263
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/Retarget.c
vendored
Normal file
@ -0,0 +1,263 @@
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <rt_sys.h>
|
||||
|
||||
|
||||
#include <File_Config.h>
|
||||
|
||||
#pragma import(__use_no_semihosting_swi)
|
||||
|
||||
/* The following macro definitions may be used to translate this file:
|
||||
|
||||
STDIO - use standard Input/Output device
|
||||
(default is NOT used)
|
||||
*/
|
||||
|
||||
/* Standard IO device handles. */
|
||||
#define STDIN 0x8001
|
||||
#define STDOUT 0x8002
|
||||
#define STDERR 0x8003
|
||||
|
||||
/* Standard IO device name defines. */
|
||||
const char __stdin_name[] = "STDIN";
|
||||
const char __stdout_name[] = "STDOUT";
|
||||
const char __stderr_name[] = "STDERR";
|
||||
|
||||
struct __FILE { int handle; /* Add whatever you need here */ };
|
||||
|
||||
#ifdef STDIO
|
||||
extern int SER_GetChar (void);
|
||||
extern int SER_PutChar (int ch);
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Write character to the Serial Port
|
||||
*----------------------------------------------------------------------------*/
|
||||
int sendchar (int c)
|
||||
{
|
||||
if (c == '\n') {
|
||||
SER_PutChar ('\r');
|
||||
}
|
||||
SER_PutChar (c);
|
||||
return (c);
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Read character from the Serial Port
|
||||
*----------------------------------------------------------------------------*/
|
||||
int getkey (void)
|
||||
{
|
||||
int ch = SER_GetChar();
|
||||
#if defined (HAVE_KEIL_RTX)
|
||||
os_itv_wait ();
|
||||
#endif
|
||||
if (ch < 0) {
|
||||
return 0;
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*--------------------------- _ttywrch ---------------------------------------*/
|
||||
|
||||
void _ttywrch (int ch)
|
||||
{
|
||||
#ifdef STDIO
|
||||
sendchar (ch);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_open --------------------------------------*/
|
||||
#ifndef NO_FILESYSTEM
|
||||
static int KEIL_FS_open(const char *name, int openmode)
|
||||
{
|
||||
int i ; int ret ;
|
||||
#define PATHSIZE 100
|
||||
char path[PATHSIZE] ; char *p ;
|
||||
|
||||
if(strlen(name) > PATHSIZE)return(-1) ;
|
||||
|
||||
for(i = 0; i<= strlen(name); i++) {
|
||||
if(name[i] == '/')path[i] = '\\' ;
|
||||
else path[i] = name[i] ;
|
||||
}
|
||||
if(path[0] == '.' && path[1] == '\\') p = path + 2 ;
|
||||
else p = path ;
|
||||
|
||||
ret = __sys_open (p, openmode) ;
|
||||
|
||||
return(ret) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
FILEHANDLE _sys_open (const char *name, int openmode)
|
||||
{
|
||||
/* Register standard Input Output devices. */
|
||||
if (strcmp(name, "STDIN") == 0) {
|
||||
return (STDIN);
|
||||
}
|
||||
if (strcmp(name, "STDOUT") == 0) {
|
||||
return (STDOUT);
|
||||
}
|
||||
if (strcmp(name, "STDERR") == 0) {
|
||||
return (STDERR);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (KEIL_FS_open(name, openmode));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_close -------------------------------------*/
|
||||
|
||||
int _sys_close (FILEHANDLE fh)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (0);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_close (fh));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_write -------------------------------------*/
|
||||
|
||||
int _sys_write (FILEHANDLE fh, const U8 *buf, U32 len, int mode)
|
||||
{
|
||||
#ifdef STDIO
|
||||
if (fh == STDOUT) {
|
||||
/* Standard Output device. */
|
||||
for ( ; len; len--) {
|
||||
sendchar (*buf++);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
if (fh > 0x8000) {
|
||||
return (-1);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_write (fh, buf, len));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_read --------------------------------------*/
|
||||
|
||||
int _sys_read (FILEHANDLE fh, U8 *buf, U32 len, int mode)
|
||||
{
|
||||
#ifdef STDIO
|
||||
if (fh == STDIN) {
|
||||
/* Standard Input device. */
|
||||
int sz ;
|
||||
while((buf[0] = getkey()) == 0) ;
|
||||
;
|
||||
for (sz = 0 ; sz <= len ; sz ++ ) {
|
||||
if(buf[sz] == 0) break ;
|
||||
else sz++ ;
|
||||
buf[sz] = getkey ();
|
||||
}
|
||||
return (sz);
|
||||
}
|
||||
#endif
|
||||
if (fh > 0x8000) {
|
||||
return (-1);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_read (fh, buf, len));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_istty -------------------------------------*/
|
||||
|
||||
int _sys_istty (FILEHANDLE fh)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_seek --------------------------------------*/
|
||||
|
||||
int _sys_seek (FILEHANDLE fh, long pos)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (-1);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_seek (fh, pos));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_ensure ------------------------------------*/
|
||||
|
||||
int _sys_ensure (FILEHANDLE fh)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (-1);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_ensure (fh));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_flen --------------------------------------*/
|
||||
|
||||
long _sys_flen (FILEHANDLE fh)
|
||||
{
|
||||
if (fh > 0x8000) {
|
||||
return (0);
|
||||
}
|
||||
#ifndef NO_FILESYSTEM
|
||||
return (__sys_flen (fh));
|
||||
#else
|
||||
return(0) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------- _sys_tmpnam ------------------------------------*/
|
||||
|
||||
int _sys_tmpnam (char *name, int sig, unsigned maxlen)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_command_string ----------------------------*/
|
||||
|
||||
char *_sys_command_string (char *cmd, int len)
|
||||
{
|
||||
return (cmd);
|
||||
}
|
||||
|
||||
/*--------------------------- _sys_exit --------------------------------------*/
|
||||
|
||||
void _sys_exit (int return_code)
|
||||
{
|
||||
#ifdef WOLFSSL_MDK_SHELL
|
||||
return ;
|
||||
#else
|
||||
/* Endless loop. */
|
||||
while (1);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
29
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.c
vendored
Normal file
29
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.c
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/* certs_test.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
/* Define initial data for cert buffers */
|
||||
#include <wolfssl/certs_test.h>
|
||||
|
||||
39
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.h
vendored
Normal file
39
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/cert_data.h
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef WOLFSSL_CERT_DATA_H
|
||||
#define WOLFSSL_CERT_DATA_H
|
||||
|
||||
#ifdef USE_CERT_BUFFERS_1024
|
||||
extern const unsigned char client_key_der_1024[] ;
|
||||
extern int sizeof_client_key_der_1024 ;
|
||||
/* ./certs/1024/client-cert.der, 1024-bit */
|
||||
extern const unsigned char client_cert_der_1024[] ;
|
||||
extern int sizeof_client_cert_der_1024 ;
|
||||
/* ./certs/1024/dh1024.der, 1024-bit */
|
||||
extern const unsigned char dh_key_der_1024[] ;
|
||||
extern int sizeof_dh_key_der_1024 ;
|
||||
/* ./certs/1024/dsa1024.der, 1024-bit */
|
||||
extern const unsigned char dsa_key_der_1024[] ;
|
||||
extern int sizeof_dsa_key_der_1024 ;
|
||||
/* ./certs/1024/rsa1024.der, 1024-bit */
|
||||
extern const unsigned char rsa_key_der_1024[] ;
|
||||
extern int sizeof_rsa_key_der_1024 ;
|
||||
|
||||
#elif defined(USE_CERT_BUFFERS_2048)
|
||||
/* ./certs/client-key.der, 2048-bit */
|
||||
extern const unsigned char client_key_der_2048[] ;
|
||||
extern int sizeof_client_key_der_2048 ;
|
||||
/* ./certs/client-cert.der, 2048-bit */
|
||||
extern const unsigned char client_cert_der_2048[] ;
|
||||
extern int sizeof_client_cert_der_2048 ;
|
||||
/* ./certs/dh2048.der, 2048-bit */
|
||||
extern const unsigned char dh_key_der_2048[] ;
|
||||
extern int sizeof_dh_key_der_2048 ;
|
||||
/* ./certs/dsa2048.der, 2048-bit */
|
||||
extern const unsigned char dsa_key_der_2048[] ;
|
||||
extern int sizeof_dsa_key_der_2048;
|
||||
/* ./certs/rsa2048.der, 2048-bit */
|
||||
extern const unsigned char rsa_key_der_2048[] ;
|
||||
extern int sizeof_rsa_key_der_2048 ;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
293
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h
vendored
Normal file
293
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-BARE-METAL.h
vendored
Normal file
@ -0,0 +1,293 @@
|
||||
/* config-BEREFOOT.h
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**** wolfSSL for KEIL-RL Configuration ****/
|
||||
|
||||
#define __CORTEX_M3__
|
||||
#define WOLFSSL_MDK_ARM
|
||||
#define NO_WRITEV
|
||||
#define NO_WOLFSSL_DIR
|
||||
//#define NO_MAIN_DRIVER
|
||||
|
||||
#define WOLFSSL_DER_LOAD
|
||||
#define HAVE_NULL_CIPHER
|
||||
|
||||
#define SINGLE_THREADED
|
||||
#define NO_FILESYSTEM
|
||||
#define NO_TLS
|
||||
#define WOLFSSL_USER_IO
|
||||
|
||||
#define NO_ECHOSERVER
|
||||
#define NO_ECHOCLIENT
|
||||
#define NO_SIMPLE_SERVER
|
||||
#define NO_SIMPLE_CLIENT
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <h> Build Target: KEIL-BAREFOOT
|
||||
// <h> Single Threaded, No File System, No TCP-net
|
||||
// </h>
|
||||
// <e>Command Shell
|
||||
#define MDK_CONF_SHELL 1
|
||||
#if MDK_CONF_SHELL == 1
|
||||
#define WOLFSSL_MDK_SHELL
|
||||
#endif
|
||||
// </e>
|
||||
// <h>wolfSSL Apps
|
||||
// <h>Crypt/Cipher
|
||||
// <o>Cert Storage <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes)
|
||||
#define MDK_CONF_CERT_BUFF 1
|
||||
#if MDK_CONF_CERT_BUFF == 1
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
#elif MDK_CONF_CERT_BUFF == 2
|
||||
#define USE_CERT_BUFFERS_2048
|
||||
#endif
|
||||
|
||||
// <e>Crypt/Cipher Test Suite
|
||||
#define MDK_CONF_CTaoCryptTest 1
|
||||
#if MDK_CONF_CTaoCryptTest == 0
|
||||
#define NO_CRYPT_TEST
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Crypt/Cipher Benchmark
|
||||
#define MDK_CONF_CTaoCryptBenchmark 1
|
||||
#if MDK_CONF_CTaoCryptBenchmark == 0
|
||||
#define NO_CRYPT_BENCHMARK
|
||||
#define BENCH_EMBEDDED
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
|
||||
// <h>STM32 Hardware Crypt
|
||||
// <e>STM32F2 Hardware RNG
|
||||
#define MDK_CONF_STM32F2_RNG 0
|
||||
#if MDK_CONF_STM32F2_RNG == 1
|
||||
#define STM32F2_RNG
|
||||
#else
|
||||
#define NO_DEV_RANDOM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>STM32F2 Hardware Crypt
|
||||
#define MDK_CONF_STM32F2_CRYPTO 0
|
||||
#if MDK_CONF_STM32F2_CRYPTO == 1
|
||||
#define STM32F2_CRYPTO
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// </h>
|
||||
|
||||
|
||||
// <h>wolfCrypt Library
|
||||
|
||||
// <h>MD5, SHA, SHA-256, AES, RC4, ASN, RSA
|
||||
// </h>
|
||||
// <e>MD2
|
||||
#define MDK_CONF_MD2 0
|
||||
#if MDK_CONF_MD2 == 1
|
||||
#define WOLFSSL_MD2
|
||||
#endif
|
||||
// </e>
|
||||
// <e>MD4
|
||||
#define MDK_CONF_MD4 1
|
||||
#if MDK_CONF_MD4 == 0
|
||||
#define NO_MD4
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-384
|
||||
// <i>This has to be with SHA512
|
||||
#define MDK_CONF_SHA384 0
|
||||
#if MDK_CONF_SHA384 == 1
|
||||
#define WOLFSSL_SHA384
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-512
|
||||
#define MDK_CONF_SHA512 0
|
||||
#if MDK_CONF_SHA512 == 1
|
||||
#define WOLFSSL_SHA512
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RIPEMD
|
||||
#define MDK_CONF_RIPEMD 0
|
||||
#if MDK_CONF_RIPEMD == 1
|
||||
#define WOLFSSL_RIPEMD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HMAC
|
||||
#define MDK_CONF_HMAC 1
|
||||
#if MDK_CONF_HMAC == 0
|
||||
#define NO_HMAC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HC128
|
||||
#define MDK_CONF_HC128 0
|
||||
#if MDK_CONF_HC128 == 1
|
||||
#define HAVE_HC128
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RABBIT
|
||||
#define MDK_CONF_RABBIT 1
|
||||
#if MDK_CONF_RABBI == 0
|
||||
#define NO_RABBIT
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>AEAD
|
||||
#define MDK_CONF_AEAD 0
|
||||
#if MDK_CONF_AEAD == 1
|
||||
#define HAVE_AEAD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DES3
|
||||
#define MDK_CONF_DES3 1
|
||||
#if MDK_CONF_DES3 == 0
|
||||
#define NO_DES3
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CAMELLIA
|
||||
#define MDK_CONF_CAMELLIA 0
|
||||
#if MDK_CONF_CAMELLIA == 1
|
||||
#define HAVE_CAMELLIA
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>DH
|
||||
// <i>need this for WOLFSSL_SERVER, OPENSSL_EXTRA
|
||||
#define MDK_CONF_DH 1
|
||||
#if MDK_CONF_DH == 0
|
||||
#define NO_DH
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DSA
|
||||
#define MDK_CONF_DSA 1
|
||||
#if MDK_CONF_DSA == 0
|
||||
#define NO_DSA
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PWDBASED
|
||||
#define MDK_CONF_PWDBASED 1
|
||||
#if MDK_CONF_PWDBASED == 0
|
||||
#define NO_PWDBASED
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>ECC
|
||||
#define MDK_CONF_ECC 0
|
||||
#if MDK_CONF_ECC == 1
|
||||
#define HAVE_ECC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PSK
|
||||
#define MDK_CONF_PSK 1
|
||||
#if MDK_CONF_PSK == 0
|
||||
#define NO_PSK
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESCCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESCCM 0
|
||||
#if MDK_CONF_AESCCM == 1
|
||||
#define HAVE_AESCCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESGCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESGCM 0
|
||||
#if MDK_CONF_AESGCM == 1
|
||||
#define HAVE_AESGCM
|
||||
#define BUILD_AESGCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>NTRU (need License, "crypto_ntru.h")
|
||||
#define MDK_CONF_NTRU 0
|
||||
#if MDK_CONF_NTRU == 1
|
||||
#define HAVE_NTRU
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
|
||||
// <h>Others
|
||||
|
||||
// <e>Inline
|
||||
#define MDK_CONF_INLINE 0
|
||||
#if MDK_CONF_INLINE == 0
|
||||
#define NO_INLINE
|
||||
#endif
|
||||
// </e>
|
||||
// <h>Debug
|
||||
// <e>Debug Message
|
||||
#define MDK_CONF_DebugMessage 0
|
||||
#if MDK_CONF_DebugMessage == 1
|
||||
#define DEBUG_WOLFSSL
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Check malloc
|
||||
#define MDK_CONF_CheckMalloc 1
|
||||
#if MDK_CONF_CheckMalloc == 1
|
||||
#define WOLFSSL_MALLOC_CHECK
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
|
||||
// </h>
|
||||
// <e>ErrNo.h
|
||||
#define MDK_CONF_ErrNo 0
|
||||
#if MDK_CONF_ErrNo == 1
|
||||
#define HAVE_ERRNO
|
||||
#endif
|
||||
// </e>
|
||||
// <e>zlib (need "zlib.h")
|
||||
#define MDK_CONF_LIBZ 0
|
||||
#if MDK_CONF_LIBZ == 1
|
||||
#define HAVE_LIBZ
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CAVIUM (need CAVIUM headers)
|
||||
#define MDK_CONF_CAVIUM 0
|
||||
#if MDK_CONF_CAVIUM == 1
|
||||
#define HAVE_CAVIUM
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>Error Strings
|
||||
#define MDK_CONF_ErrorStrings 1
|
||||
#if MDK_CONF_ErrorStrings == 0
|
||||
#define NO_ERROR_STRINGS
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>Small Stack
|
||||
#define MDK_CONF_SmallStack 1
|
||||
#if MDK_CONF_SmallStack == 0
|
||||
#define NO_WOLFSSL_SMALL_STACK
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Use Fast Math
|
||||
#define MDK_CONF_FASTMATH 0
|
||||
#if MDK_CONF_FASTMATH == 1
|
||||
#define USE_FAST_MATH
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
|
||||
// </h>
|
||||
|
||||
//</h>
|
||||
// <<< end of configuration section >>>
|
||||
330
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h
vendored
Normal file
330
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-FS.h
vendored
Normal file
@ -0,0 +1,330 @@
|
||||
/* config-FS.h
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**** wolfSSL for KEIL-RL Configuration ****/
|
||||
|
||||
#define __CORTEX_M3__
|
||||
#define WOLFSSL_KEIL_RL
|
||||
#define NO_WRITEV
|
||||
#define NO_WOLFSSL_DIR
|
||||
#define NO_MAIN_DRIVER
|
||||
#define WOLFSSL_USER_IO
|
||||
|
||||
#define WOLFSSL_DER_LOAD
|
||||
#define HAVE_NULL_CIPHER
|
||||
|
||||
#define SINGLE_THREADED
|
||||
|
||||
#define NO_ECHOSERVER
|
||||
#define NO_ECHOCLIENT
|
||||
#define NO_SIMPLE_SERVER
|
||||
#define NO_SIMPLE_CLIENT
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <h> Build Target: KEIL-FS
|
||||
// <h> Single Threaded, With File System, No TCP-net
|
||||
// </h>
|
||||
// <e>Command Shell
|
||||
#define MDK_CONF_SHELL 1
|
||||
#if MDK_CONF_SHELL == 1
|
||||
#define WOLFSSL_MDK_SHELL
|
||||
#endif
|
||||
// </e>
|
||||
// <h>wolfSSL Apps
|
||||
// <h>Crypt/Cipher
|
||||
// <o>Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes)
|
||||
#define MDK_CONF_CERT_BUFF 0
|
||||
#if MDK_CONF_CERT_BUFF== 1
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
#elif MDK_CONF_CERT_BUFF == 2
|
||||
#define USE_CERT_BUFFERS_2048
|
||||
#endif
|
||||
|
||||
// <e>Crypt/Cipher Test Suite
|
||||
#define MDK_CONF_CTaoCryptTest 1
|
||||
#if MDK_CONF_CTaoCryptTest == 0
|
||||
#define NO_CRYPT_TEST
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Crypt/Cipher Benchmark
|
||||
#define MDK_CONF_CTaoCryptBenchmark 1
|
||||
#if MDK_CONF_CTaoCryptBenchmark == 0
|
||||
#define NO_CRYPT_BENCHMARK
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
|
||||
// <h>STM32 Hardware Crypt
|
||||
// <e>STM32F2 Hardware RNG
|
||||
#define MDK_CONF_STM32F2_RNG 0
|
||||
#if MDK_CONF_STM32F2_RNG == 1
|
||||
#define STM32F2_RNG
|
||||
#else
|
||||
#define NO_DEV_RANDOM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>STM32F2 Hardware Crypt
|
||||
#define MDK_CONF_STM32F2_CRYPTO 0
|
||||
#if MDK_CONF_STM32F2_CRYPTO == 1
|
||||
#define STM32F2_CRYPTO
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// </h>
|
||||
|
||||
// <h>wolfSSL Library
|
||||
// <h>SSL (Included by default)
|
||||
// </h>
|
||||
|
||||
// <e>TLS
|
||||
#define MDK_CONF_TLS 1
|
||||
#if MDK_CONF_TLS == 0
|
||||
#define NO_TLS
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>CertGen
|
||||
#define MDK_CONF_CERT_GEN 0
|
||||
#if MDK_CONF_CERT_GEN == 1
|
||||
#define WOLFSSL_CERT_GEN
|
||||
#endif
|
||||
// </e>
|
||||
// <e>KeyGen
|
||||
#define MDK_CONF_KEY_GEN 0
|
||||
#if MDK_CONF_KEY_GEN == 1
|
||||
#define WOLFSSL_KEY_GEN
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CRL
|
||||
#define MDK_CONF_DER_LOAD 0
|
||||
#if MDK_CONF_DER_LOAD == 1
|
||||
#define WOLFSSL_DER_LOAD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>OpenSSL Extra
|
||||
#define MDK_CONF_OPENSSL_EXTRA 0
|
||||
#if MDK_CONF_OPENSSL_EXTRA == 1
|
||||
#define OPENSSL_EXTRA
|
||||
#endif
|
||||
// </e>
|
||||
// <h>CRL Monitor, OCSP (not supported with KEIL)
|
||||
// </h>
|
||||
|
||||
// </h>
|
||||
|
||||
// <h>wolfCrypt Library
|
||||
|
||||
// <h>MD5, SHA, SHA-256, AES, RC4, ASN, RSA
|
||||
// </h>
|
||||
|
||||
// <e>MD2
|
||||
#define MDK_CONF_MD2 0
|
||||
#if MDK_CONF_MD2 == 1
|
||||
#define WOLFSSL_MD2
|
||||
#endif
|
||||
// </e>
|
||||
// <e>MD4
|
||||
#define MDK_CONF_MD4 1
|
||||
#if MDK_CONF_MD4 == 0
|
||||
#define NO_MD4
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-384
|
||||
// <i>This has to be with SHA512
|
||||
#define MDK_CONF_SHA384 0
|
||||
#if MDK_CONF_SHA384 == 1
|
||||
#define WOLFSSL_SHA384
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-512
|
||||
#define MDK_CONF_SHA512 0
|
||||
#if MDK_CONF_SHA512 == 1
|
||||
#define WOLFSSL_SHA512
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RIPEMD
|
||||
#define MDK_CONF_RIPEMD 0
|
||||
#if MDK_CONF_RIPEMD == 1
|
||||
#define WOLFSSL_RIPEMD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HMAC
|
||||
#define MDK_CONF_HMAC 1
|
||||
#if MDK_CONF_HMAC == 0
|
||||
#define NO_HMAC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HC128
|
||||
#define MDK_CONF_HC128 0
|
||||
#if MDK_CONF_HC128 == 1
|
||||
#define HAVE_HC128
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RABBIT
|
||||
#define MDK_CONF_RABBIT 1
|
||||
#if MDK_CONF_RABBI == 0
|
||||
#define NO_RABBIT
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>AEAD
|
||||
#define MDK_CONF_AEAD 0
|
||||
#if MDK_CONF_AEAD == 1
|
||||
#define HAVE_AEAD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DES3
|
||||
#define MDK_CONF_DES3 1
|
||||
#if MDK_CONF_DES3 == 0
|
||||
#define NO_DES3
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CAMELLIA
|
||||
#define MDK_CONF_CAMELLIA 0
|
||||
#if MDK_CONF_CAMELLIA == 1
|
||||
#define HAVE_CAMELLIA
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>DH
|
||||
// <i>need this for WOLFSSL_SERVER, OPENSSL_EXTRA
|
||||
#define MDK_CONF_DH 1
|
||||
#if MDK_CONF_DH == 0
|
||||
#define NO_DH
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DSA
|
||||
#define MDK_CONF_DSA 1
|
||||
#if MDK_CONF_DSA == 0
|
||||
#define NO_DSA
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PWDBASED
|
||||
#define MDK_CONF_PWDBASED 1
|
||||
#if MDK_CONF_PWDBASED == 0
|
||||
#define NO_PWDBASED
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>ECC
|
||||
#define MDK_CONF_ECC 0
|
||||
#if MDK_CONF_ECC == 1
|
||||
#define HAVE_ECC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PSK
|
||||
#define MDK_CONF_PSK 1
|
||||
#if MDK_CONF_PSK == 0
|
||||
#define NO_PSK
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESCCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESCCM 0
|
||||
#if MDK_CONF_AESCCM == 1
|
||||
#define HAVE_AESCCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESGCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESGCM 0
|
||||
#if MDK_CONF_AESGCM == 1
|
||||
#define HAVE_AESGCM
|
||||
#define BUILD_AESGCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>NTRU (need License, "crypto_ntru.h")
|
||||
#define MDK_CONF_NTRU 0
|
||||
#if MDK_CONF_NTRU == 1
|
||||
#define HAVE_NTRU
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
|
||||
// <h>Others
|
||||
|
||||
// <e>Inline
|
||||
#define MDK_CONF_INLINE 0
|
||||
#if MDK_CONF_INLINE == 0
|
||||
#define NO_INLINE
|
||||
#endif
|
||||
// </e>
|
||||
// <h>Debug
|
||||
// <e>Debug Message
|
||||
#define MDK_CONF_DebugMessage 0
|
||||
#if MDK_CONF_DebugMessage == 1
|
||||
#define DEBUG_WOLFSSL
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Check malloc
|
||||
#define MDK_CONF_CheckMalloc 1
|
||||
#if MDK_CONF_CheckMalloc == 1
|
||||
#define WOLFSSL_MALLOC_CHECK
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
|
||||
// </h>
|
||||
// <e>ErrNo.h
|
||||
#define MDK_CONF_ErrNo 0
|
||||
#if MDK_CONF_ErrNo == 1
|
||||
#define HAVE_ERRNO
|
||||
#endif
|
||||
// </e>
|
||||
// <e>zlib (need "zlib.h")
|
||||
#define MDK_CONF_LIBZ 0
|
||||
#if MDK_CONF_LIBZ == 1
|
||||
#define HAVE_LIBZ
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CAVIUM (need CAVIUM headers)
|
||||
#define MDK_CONF_CAVIUM 0
|
||||
#if MDK_CONF_CAVIUM == 1
|
||||
#define HAVE_CAVIUM
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>Error Strings
|
||||
#define MDK_CONF_ErrorStrings 1
|
||||
#if MDK_CONF_ErrorStrings == 0
|
||||
#define NO_ERROR_STRINGS
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>Small Stack
|
||||
#define MDK_CONF_SmallStack 1
|
||||
#if MDK_CONF_SmallStack == 0
|
||||
#define NO_WOLFSSL_SMALL_STACK
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Use Fast Math
|
||||
#define MDK_CONF_FASTMATH 0
|
||||
#if MDK_CONF_FASTMATH == 1
|
||||
#define USE_FAST_MATH
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
|
||||
// </h>
|
||||
|
||||
//</h>
|
||||
// <<< end of configuration section >>>
|
||||
354
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h
vendored
Normal file
354
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-RTX-TCP-FS.h
vendored
Normal file
@ -0,0 +1,354 @@
|
||||
/* config-RTX-TCP-FS.h
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**** wolfSSL for MDK-RTX-TCP-FS Configuration ****/
|
||||
|
||||
#define __CORTEX_M3__
|
||||
#define WOLFSSL_MDK_ARM
|
||||
#define NO_WRITEV
|
||||
#define NO_WOLFSSL_DIR
|
||||
#define NO_MAIN_DRIVER
|
||||
|
||||
#define WOLFSSL_DER_LOAD
|
||||
#define HAVE_NULL_CIPHER
|
||||
|
||||
#define HAVE_KEIL_RTX
|
||||
#define WOLFSSL_KEIL_TCP_NET
|
||||
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
// <h> Build Target: KEIL-RTX-TCP-FS
|
||||
// <h> RTOS, File System and TCP-net
|
||||
// </h>
|
||||
// <e>Command Shell
|
||||
#define MDK_CONF_SHELL 1
|
||||
#if MDK_CONF_SHELL == 1
|
||||
#define WOLFSSL_MDK_SHELL
|
||||
#endif
|
||||
// </e>
|
||||
// <h>wolfSSL Apps
|
||||
// <h>Crypt/Cipher
|
||||
// <o>Cert Storage <0=> SD Card <1=> Mem Buff (1024bytes) <2=> Mem Buff (2048bytes)
|
||||
#define MDK_CONF_CERT_BUFF 0
|
||||
#if MDK_CONF_CERT_BUFF== 1
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
#elif MDK_CONF_CERT_BUFF == 2
|
||||
#define USE_CERT_BUFFERS_2048
|
||||
#endif
|
||||
|
||||
// <e>Crypt/Cipher Test Suite
|
||||
#define MDK_CONF_CTaoCryptTest 1
|
||||
#if MDK_CONF_CTaoCryptTest == 0
|
||||
#define NO_CRYPT_TEST
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Crypt/Cipher Benchmark
|
||||
#define MDK_CONF_CTaoCryptBenchmark 1
|
||||
#if MDK_CONF_CTaoCryptBenchmark == 0
|
||||
#define NO_CRYPT_BENCHMARK
|
||||
#define BENCH_EMBEDDED
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
// <h>SSL/TLS Server/Client
|
||||
// <e>echoServer
|
||||
#define MDK_CONF_echoServer 1
|
||||
#if MDK_CONF_echoServer == 0
|
||||
#define NO_ECHOSERVER
|
||||
#endif
|
||||
// </e>
|
||||
// <e>echoClient
|
||||
#define MDK_CONF_echoClient 1
|
||||
#if MDK_CONF_echoClient == 0
|
||||
#define NO_ECHOCLIENT
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SimpleServer
|
||||
#define MDK_CONF_simpleServer 1
|
||||
#if MDK_CONF_simpleServer == 0
|
||||
#define NO_SIMPLE_SERVER
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SimpleCliet
|
||||
#define MDK_CONF_simpleClient 1
|
||||
#if MDK_CONF_simpleClient == 0
|
||||
#define NO_SIMPLE_CLIENT
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
// </h>
|
||||
// <h>STM32 Hardware Crypt
|
||||
// <e>STM32F2 Hardware RNG
|
||||
#define MDK_CONF_STM32F2_RNG 0
|
||||
#if MDK_CONF_STM32F2_RNG == 1
|
||||
#define STM32F2_RNG
|
||||
#else
|
||||
#define NO_DEV_RANDOM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>STM32F2 Hardware Crypt
|
||||
#define MDK_CONF_STM32F2_CRYPTO 0
|
||||
#if MDK_CONF_STM32F2_CRYPTO == 1
|
||||
#define STM32F2_CRYPTO
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// </h>
|
||||
|
||||
// <h>wolfSSL Library
|
||||
// <h>SSL (Included by default)
|
||||
// </h>
|
||||
|
||||
// <e>TLS
|
||||
#define MDK_CONF_TLS 1
|
||||
#if MDK_CONF_TLS == 0
|
||||
#define NO_TLS
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>CertGen
|
||||
#define MDK_CONF_CERT_GEN 0
|
||||
#if MDK_CONF_CERT_GEN == 1
|
||||
#define WOLFSSL_CERT_GEN
|
||||
#endif
|
||||
// </e>
|
||||
// <e>KeyGen
|
||||
#define MDK_CONF_KEY_GEN 0
|
||||
#if MDK_CONF_KEY_GEN == 1
|
||||
#define WOLFSSL_KEY_GEN
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CRL
|
||||
#define MDK_CONF_DER_LOAD 0
|
||||
#if MDK_CONF_DER_LOAD == 1
|
||||
#define WOLFSSL_DER_LOAD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>OpenSSL Extra
|
||||
#define MDK_CONF_OPENSSL_EXTRA 0
|
||||
#if MDK_CONF_OPENSSL_EXTRA == 1
|
||||
#define OPENSSL_EXTRA
|
||||
#endif
|
||||
// </e>
|
||||
// <h>CRL Monitor, OCSP (not supported with KEIL)
|
||||
// </h>
|
||||
|
||||
// </h>
|
||||
|
||||
// <h>wolfCrypt Library
|
||||
|
||||
// <h>MD5, SHA, SHA-256, AES, RC4, ASN, RSA
|
||||
// </h>
|
||||
// <e>MD2
|
||||
#define MDK_CONF_MD2 0
|
||||
#if MDK_CONF_MD2 == 1
|
||||
#define WOLFSSL_MD2
|
||||
#endif
|
||||
// </e>
|
||||
// <e>MD4
|
||||
#define MDK_CONF_MD4 0
|
||||
#if MDK_CONF_MD4 == 0
|
||||
#define NO_MD4
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-384
|
||||
// <i>This has to be with SHA512
|
||||
#define MDK_CONF_SHA384 0
|
||||
#if MDK_CONF_SHA384 == 1
|
||||
#define WOLFSSL_SHA384
|
||||
#endif
|
||||
// </e>
|
||||
// <e>SHA-512
|
||||
#define MDK_CONF_SHA512 0
|
||||
#if MDK_CONF_SHA512 == 1
|
||||
#define WOLFSSL_SHA512
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RIPEMD
|
||||
#define MDK_CONF_RIPEMD 0
|
||||
#if MDK_CONF_RIPEMD == 1
|
||||
#define WOLFSSL_RIPEMD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HMAC
|
||||
#define MDK_CONF_HMAC 1
|
||||
#if MDK_CONF_HMAC == 0
|
||||
#define NO_HMAC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>HC128
|
||||
#define MDK_CONF_HC128 0
|
||||
#if MDK_CONF_HC128 == 1
|
||||
#define HAVE_HC128
|
||||
#endif
|
||||
// </e>
|
||||
// <e>RABBIT
|
||||
#define MDK_CONF_RABBIT 1
|
||||
#if MDK_CONF_RABBI == 0
|
||||
#define NO_RABBIT
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>AEAD
|
||||
#define MDK_CONF_AEAD 0
|
||||
#if MDK_CONF_AEAD == 1
|
||||
#define HAVE_AEAD
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DES3
|
||||
#define MDK_CONF_DES3 0
|
||||
#if MDK_CONF_DES3 == 0
|
||||
#define NO_DES3
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CAMELLIA
|
||||
#define MDK_CONF_CAMELLIA 0
|
||||
#if MDK_CONF_CAMELLIA == 1
|
||||
#define HAVE_CAMELLIA
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>DH
|
||||
// <i>need this for WOLFSSL_SERVER, OPENSSL_EXTRA
|
||||
#define MDK_CONF_DH 1
|
||||
#if MDK_CONF_DH == 0
|
||||
#define NO_DH
|
||||
#endif
|
||||
// </e>
|
||||
// <e>DSA
|
||||
#define MDK_CONF_DSA 1
|
||||
#if MDK_CONF_DSA == 0
|
||||
#define NO_DSA
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PWDBASED
|
||||
#define MDK_CONF_PWDBASED 1
|
||||
#if MDK_CONF_PWDBASED == 0
|
||||
#define NO_PWDBASED
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>ECC
|
||||
#define MDK_CONF_ECC 0
|
||||
#if MDK_CONF_ECC == 1
|
||||
#define HAVE_ECC
|
||||
#endif
|
||||
// </e>
|
||||
// <e>PSK
|
||||
#define MDK_CONF_PSK 1
|
||||
#if MDK_CONF_PSK == 0
|
||||
#define NO_PSK
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESCCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESCCM 0
|
||||
#if MDK_CONF_AESCCM == 1
|
||||
#define HAVE_AESCCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>AESGCM (Turn off Hardware Crypt)
|
||||
#define MDK_CONF_AESGCM 0
|
||||
#if MDK_CONF_AESGCM == 1
|
||||
#define HAVE_AESGCM
|
||||
#define BUILD_AESGCM
|
||||
#endif
|
||||
// </e>
|
||||
// <e>NTRU (need License, "crypto_ntru.h")
|
||||
#define MDK_CONF_NTRU 0
|
||||
#if MDK_CONF_NTRU == 1
|
||||
#define HAVE_NTRU
|
||||
#endif
|
||||
// </e>
|
||||
// </h>
|
||||
|
||||
// <h>Others
|
||||
|
||||
// <e>Inline
|
||||
#define MDK_CONF_INLINE 0
|
||||
#if MDK_CONF_INLINE == 0
|
||||
#define NO_INLINE
|
||||
#endif
|
||||
// </e>
|
||||
// <h>Debug
|
||||
// <e>Debug Message
|
||||
#define MDK_CONF_DEBUG_MSG 0
|
||||
#if MDK_CONF_DEBUG_MSG == 1
|
||||
#define DEBUG_WOLFSSL
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Check malloc
|
||||
#define MDK_CONF_CHECK_MALLOC 1
|
||||
#if MDK_CONF_CHECK_MALLOC == 1
|
||||
#define WOLFSSL_MALLOC_CHECK
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
|
||||
// </h>
|
||||
// <e>ErrNo.h
|
||||
#define MDK_CONF_ERR_NO 0
|
||||
#if MDK_CONF_ERR_NO == 1
|
||||
#define HAVE_ERRNO
|
||||
#endif
|
||||
// </e>
|
||||
// <e>zlib (need "zlib.h")
|
||||
#define MDK_CONF_LIBZ 0
|
||||
#if MDK_CONF_LIBZ == 1
|
||||
#define HAVE_LIBZ
|
||||
#endif
|
||||
// </e>
|
||||
// <e>CAVIUM (need CAVIUM headers)
|
||||
#define MDK_CONF_CAVIUM 0
|
||||
#if MDK_CONF_CAVIUM == 1
|
||||
#define HAVE_CAVIUM
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>Error Strings
|
||||
#define MDK_CONF_ErrorStrings 0
|
||||
#if MDK_CONF_ErrorStrings == 0
|
||||
#define NO_ERROR_STRINGS
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
// <e>Small Stack
|
||||
#define MDK_CONF_SMALL_STACK 1
|
||||
#if MDK_CONF_SMALL_STACK == 0
|
||||
#define NO_WOLFSSL_SMALL_STACK
|
||||
#endif
|
||||
// </e>
|
||||
// <e>Use Fast Math
|
||||
#define MDK_CONF_FASTMATH 1
|
||||
#if MDK_CONF_FASTMATH == 1
|
||||
#define USE_FAST_MATH
|
||||
#define TFM_TIMING_RESISTANT
|
||||
#endif
|
||||
// </e>
|
||||
|
||||
|
||||
// </h>
|
||||
|
||||
//</h>
|
||||
// <<< end of configuration section >>>
|
||||
|
||||
13
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-WOLFLIB.h
vendored
Normal file
13
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/config-WOLFLIB.h
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
#define SINGLE_THREADED /* or define RTOS option */
|
||||
|
||||
#define WOLFSSL_USER_IO /* Use own TCP/IP lib */
|
||||
|
||||
#define NO_DEV_RANDOM
|
||||
#define WOLFSSL_MDK_ARM
|
||||
|
||||
#define NO_WOLFSSL_DIR
|
||||
#define NO_WRITEV
|
||||
|
||||
#define USE_FAST_MATH
|
||||
#define TFM_TIMING_RESISTANT
|
||||
169
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c
vendored
Normal file
169
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/main.c
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
/* main.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/visibility.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
|
||||
#include <RTL.h>
|
||||
#include <stdio.h>
|
||||
#include "wolfssl_MDK_ARM.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Initialize a Flash Memory Card
|
||||
*----------------------------------------------------------------------------*/
|
||||
#if !defined(NO_FILESYSTEM)
|
||||
static void init_card (void)
|
||||
{
|
||||
U32 retv;
|
||||
|
||||
while ((retv = finit (NULL)) != 0) { /* Wait until the Card is ready */
|
||||
if (retv == 1) {
|
||||
printf ("\nSD/MMC Init Failed");
|
||||
printf ("\nInsert Memory card and press key...\n");
|
||||
} else {
|
||||
printf ("\nSD/MMC Card is Unformatted");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* TCP/IP tasks
|
||||
*----------------------------------------------------------------------------*/
|
||||
#ifdef WOLFSSL_KEIL_TCP_NET
|
||||
__task void tcp_tick (void)
|
||||
{
|
||||
|
||||
WOLFSSL_MSG("Time tick started.") ;
|
||||
#if defined (HAVE_KEIL_RTX)
|
||||
os_itv_set (10);
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
#if defined (HAVE_KEIL_RTX)
|
||||
os_itv_wait ();
|
||||
#endif
|
||||
/* Timer tick every 100 ms */
|
||||
timer_tick ();
|
||||
}
|
||||
}
|
||||
|
||||
__task void tcp_poll (void)
|
||||
{
|
||||
WOLFSSL_MSG("TCP polling started.\n") ;
|
||||
while (1) {
|
||||
main_TcpNet ();
|
||||
#if defined (HAVE_KEIL_RTX)
|
||||
os_tsk_pass ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_KEIL_RTX) && defined(WOLFSSL_MDK_SHELL)
|
||||
#define SHELL_STACKSIZE 1000
|
||||
static unsigned char Shell_stack[SHELL_STACKSIZE] ;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(WOLFSSL_MDK_SHELL)
|
||||
extern void shell_main(void) ;
|
||||
#endif
|
||||
|
||||
extern void time_main(int) ;
|
||||
extern void benchmark_test(void) ;
|
||||
extern void SER_Init(void) ;
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* mian entry
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*** This is the parent task entry ***/
|
||||
void main_task (void)
|
||||
{
|
||||
#ifdef WOLFSSL_KEIL_TCP_NET
|
||||
init_TcpNet ();
|
||||
|
||||
os_tsk_create (tcp_tick, 2);
|
||||
os_tsk_create (tcp_poll, 1);
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_MDK_SHELL
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
os_tsk_create_user(shell_main, 1, Shell_stack, SHELL_STACKSIZE) ;
|
||||
#else
|
||||
shell_main() ;
|
||||
#endif
|
||||
#else
|
||||
|
||||
/************************************/
|
||||
/*** USER APPLICATION HERE ***/
|
||||
/************************************/
|
||||
printf("USER LOGIC STARTED\n") ;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
WOLFSSL_MSG("Terminating tcp_main\n") ;
|
||||
os_tsk_delete_self ();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
int myoptind = 0;
|
||||
char* myoptarg = NULL;
|
||||
|
||||
#if defined(DEBUG_WOLFSSL)
|
||||
extern void wolfSSL_Debugging_ON(void) ;
|
||||
#endif
|
||||
|
||||
|
||||
/*** main entry ***/
|
||||
extern void SystemInit(void);
|
||||
|
||||
int main() {
|
||||
|
||||
SystemInit();
|
||||
#if !defined(NO_FILESYSTEM)
|
||||
init_card () ; /* initializing SD card */
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_WOLFSSL)
|
||||
printf("Turning ON Debug message\n") ;
|
||||
wolfSSL_Debugging_ON() ;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
os_sys_init (main_task) ;
|
||||
#else
|
||||
main_task() ;
|
||||
#endif
|
||||
|
||||
return 0 ; /* There should be no return here */
|
||||
|
||||
}
|
||||
594
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/shell.c
vendored
Normal file
594
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/shell.c
vendored
Normal file
@ -0,0 +1,594 @@
|
||||
/*shell.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/*** tiny Shell for wolfSSL apps ***/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(WOLFSSL_MDK_ARM)
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <rtl.h>
|
||||
#include "wolfssl_MDK_ARM.h"
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_KEIL_NET
|
||||
#include "wolfassl/test.h"
|
||||
#else
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
#endif
|
||||
|
||||
#ifdef NO_ECHOCLIENT
|
||||
#define echoclient_test command_not_found
|
||||
#endif
|
||||
#ifdef NO_ECHOSERVER
|
||||
#define echoserver_test command_not_found
|
||||
#endif
|
||||
#ifdef NO_SIMPLE_CLIENT
|
||||
#define client_test command_not_found
|
||||
#endif
|
||||
#ifdef NO_SIMPLE_SERVER
|
||||
#define server_test command_not_found
|
||||
#endif
|
||||
#ifdef NO_CRYPT_BENCHMARK
|
||||
#define benchmark_test command_not_found
|
||||
#endif
|
||||
#ifdef NO_CRYPT_TEST
|
||||
#define ctaocrypt_test command_not_found
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_KEIL_NET
|
||||
#define ipaddr_comm command_not_found
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_KEIL_RTX)
|
||||
#define stack_comm command_not_found
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(DEBUG_WOLFSSL)
|
||||
#define dbg_comm command_not_found
|
||||
#endif
|
||||
|
||||
|
||||
void command_not_found(void *argv) {
|
||||
printf("Command not found\n") ;
|
||||
}
|
||||
|
||||
extern void echoclient_test(void *args) ;
|
||||
extern void echoserver_test(void *args) ;
|
||||
extern void benchmark_test(void *args) ;
|
||||
extern void wolfcrypt_test(void *args) ;
|
||||
extern void client_test(void *args) ;
|
||||
extern void server_test(void *args) ;
|
||||
extern void kill_task(void *args) ;
|
||||
|
||||
extern void ipaddr_comm(void *args) ;
|
||||
extern void stack_comm(void *args) ;
|
||||
extern void for_command(void *args) ;
|
||||
extern void dbg_comm(void *arg) ;
|
||||
extern void help_comm(void *arg) ;
|
||||
|
||||
#if !defined(NO_CRYPT_TEST)
|
||||
|
||||
#ifndef NO_MD5
|
||||
extern void md5_test(void *arg) ;
|
||||
#endif
|
||||
#ifdef WOLFSSL_MD2
|
||||
extern void md2_test(void *arg) ;
|
||||
#endif
|
||||
#ifndef NO_MD4
|
||||
extern void md4_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
extern void sha_test(void *arg) ;
|
||||
|
||||
#ifndef NO_SHA256
|
||||
extern void sha256_test(void *arg) ;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
extern void sha384_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
extern void sha512_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_RIPEMD
|
||||
extern void ripemd_test(void *arg) ;
|
||||
#endif
|
||||
#ifndef NO_HMAC
|
||||
#ifndef NO_MD5
|
||||
extern void hmac_md5_test(void *arg) ;
|
||||
#endif
|
||||
extern void hmac_sha_test(void *arg) ;
|
||||
|
||||
#ifndef NO_SHA256
|
||||
extern void hmac_sha256_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA384
|
||||
extern void hmac_sha384_test(void *arg) ;
|
||||
#endif
|
||||
#endif
|
||||
#ifndef NO_RC4
|
||||
extern void arc4_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifndef NO_HC128
|
||||
extern void hc128_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifndef NO_RABBIT
|
||||
extern void rabbit_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifndef NO_DES3
|
||||
extern void des_test(void *arg) ;
|
||||
extern void des3_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifndef NO_AES
|
||||
extern void aes_test(void *arg) ;
|
||||
#ifdef HAVE_AESGCM
|
||||
extern void aesgcm_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AESCCM
|
||||
extern void aesccm_test(void *arg) ;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CAMELLIA
|
||||
extern void camellia_test(void *arg) ;
|
||||
#endif
|
||||
extern void random_test(void *arg) ;
|
||||
|
||||
#ifndef NO_RSA
|
||||
extern void rsa_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifndef NO_DH
|
||||
extern void dh_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifndef NO_DSA
|
||||
extern void dsa_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifndef NO_PWDBASED
|
||||
extern void pwdbased_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
extern void openssl_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
extern void ecc_test(void *arg) ;
|
||||
#endif
|
||||
|
||||
#endif /* NO_CRYPT_TEST */
|
||||
|
||||
static struct {
|
||||
const char *command ;
|
||||
void (*func)(void *args) ;
|
||||
} commandTable[] = {
|
||||
"echoclient", echoclient_test,
|
||||
"echoserver", echoserver_test,
|
||||
"benchmark", benchmark_test,
|
||||
"test", wolfcrypt_test,
|
||||
"client", client_test,
|
||||
"server", server_test,
|
||||
"ipaddr", ipaddr_comm, /* TBD */
|
||||
"stack", stack_comm, /* On/Off check stack size */
|
||||
"for", for_command, /* iterate next command X times */
|
||||
"debug", dbg_comm, /* On/Off debug message */
|
||||
"help", help_comm, /* Brief description about the commands */
|
||||
|
||||
/** short name **/
|
||||
"ec", echoclient_test,
|
||||
"es", echoserver_test,
|
||||
"bm", benchmark_test,
|
||||
"te", wolfcrypt_test,
|
||||
"cl", client_test,
|
||||
"sv", server_test,
|
||||
"ip", ipaddr_comm,
|
||||
"st", stack_comm,
|
||||
"dbg", dbg_comm,
|
||||
"?", help_comm,
|
||||
|
||||
/*** test suites ****/
|
||||
#if !defined(NO_CRYPT_TEST)
|
||||
#ifndef NO_MD5
|
||||
"md5", md5_test,
|
||||
#endif
|
||||
#ifdef WOLFSSL_MD2
|
||||
"md2", md2_test,
|
||||
#endif
|
||||
#ifndef NO_MD4
|
||||
"md4", md4_test,
|
||||
#endif
|
||||
"sha", sha_test,
|
||||
#ifndef NO_SHA256
|
||||
"sha256", sha256_test,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
"sha384", sha384_test,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
"sha512", sha512_test,
|
||||
#endif
|
||||
#ifdef WOLFSSL_RIPEMD
|
||||
"ripemd", ripemd_test,
|
||||
#endif
|
||||
#ifndef NO_HMAC
|
||||
#ifndef NO_MD5
|
||||
"hmac_md5", hmac_md5_test,
|
||||
#endif
|
||||
"hmac_sha", hmac_sha_test,
|
||||
#ifndef NO_SHA256
|
||||
"hmac_sha256", hmac_sha256_test,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
"hmac_sha384", hmac_sha384_test,
|
||||
#endif
|
||||
#endif
|
||||
#ifndef NO_RC4
|
||||
"arc4", arc4_test,
|
||||
#endif
|
||||
#ifndef NO_HC128
|
||||
"hc128", hc128_test,
|
||||
#endif
|
||||
#ifndef NO_RABBIT
|
||||
"rabbit", rabbit_test,
|
||||
#endif
|
||||
#ifndef NO_DES3
|
||||
"des", des_test,
|
||||
"des3", des3_test,
|
||||
#endif
|
||||
#ifndef NO_AES
|
||||
"aes", aes_test,
|
||||
#ifdef HAVE_AESGCM
|
||||
"aesgcm", aesgcm_test,
|
||||
#endif
|
||||
#ifdef HAVE_AESCCM
|
||||
"aesccm", aesccm_test,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CAMELLIA
|
||||
"camellia", camellia_test,
|
||||
#endif
|
||||
"random", random_test,
|
||||
#ifndef NO_RSA
|
||||
"rsa", rsa_test,
|
||||
#endif
|
||||
#ifndef NO_DH
|
||||
"dh", dh_test,
|
||||
#endif
|
||||
#ifndef NO_DSA
|
||||
"dsa", dsa_test,
|
||||
#endif
|
||||
#ifndef NO_PWDBASED
|
||||
"pwdbased", pwdbased_test,
|
||||
#endif
|
||||
#ifdef OPENSSL_EXTRA
|
||||
"openssl", openssl_test,
|
||||
#endif
|
||||
#ifdef HAVE_ECC
|
||||
"ecc", ecc_test,
|
||||
#endif
|
||||
|
||||
#endif /* NO_CRYPT_TEST */
|
||||
|
||||
"", NULL
|
||||
} ;
|
||||
|
||||
enum jobtype { FORGROUND, BACKGROUND } ;
|
||||
|
||||
#define IF_DELIMITER(ch) ((ch) == ' ' || (ch) == '\n')
|
||||
|
||||
/******* Get Command Line *****************************/
|
||||
static int getline(char * line, int sz, func_args *args, int*bf_flg)
|
||||
{
|
||||
char * ret ;
|
||||
int i ;
|
||||
|
||||
#define MAXARGS 10
|
||||
#define MAXARGLEN 30
|
||||
static char *argv[MAXARGS] ;
|
||||
args->argv = argv ;
|
||||
|
||||
putchar('>') ;
|
||||
fflush(stdout) ;
|
||||
ret = fgets(line, sz, stdin) ;
|
||||
#define SHELL_ERROR_FGETS -102
|
||||
if(ret != line) return(SHELL_ERROR_FGETS) ;
|
||||
|
||||
if(line[strlen(line)-2] == '&') {
|
||||
(*bf_flg) = BACKGROUND ;
|
||||
line[strlen(line)-2] = '\n' ;
|
||||
} else {
|
||||
(*bf_flg) = FORGROUND ;
|
||||
}
|
||||
args->argc = 0 ;
|
||||
for(i=0; i<sz; i++) {
|
||||
args->argv[args->argc] = &(line[i]) ;
|
||||
while(!IF_DELIMITER(line[i])) i++ ;
|
||||
args->argc++ ;
|
||||
if(line[i] == '\n') {
|
||||
line[i] = '\0' ;
|
||||
break ;
|
||||
} else {
|
||||
line[i] = '\0' ;
|
||||
}
|
||||
}
|
||||
return i ;
|
||||
}
|
||||
|
||||
static int BackGround = 0 ; /* 1: background job is running */
|
||||
|
||||
/************* Embedded Shell Commands **********************************/
|
||||
#define IP_SIZE 16
|
||||
|
||||
#ifdef WOLFSSL_KEIL_NET
|
||||
static void ipaddr_comm(void *args)
|
||||
{
|
||||
if(((func_args *)args)->argc == 1) {
|
||||
printf("IP addr: %s, port %d\n", wolfSSLIP, wolfSSLPort) ;
|
||||
} else {
|
||||
if(BackGround != 0) {
|
||||
printf("Cannot change IP addr while background server is running\n") ;
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-'&&
|
||||
((func_args *)args)->argv[1][1] == 'a' ) {
|
||||
/* strcpy(wolfSSLIP, ((func_args *)args)->argv[2]) ; */
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-' &&
|
||||
((func_args *)args)->argv[1][1] == 'p' ) {
|
||||
/* yasslPort = atoi(((func_args *)args)->argv[2]) ; */
|
||||
} else printf("Invalid argument\n") ;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(HAVE_KEIL_RTX)
|
||||
static int stack_ck = 0 ;
|
||||
|
||||
static void stack_comm(void *args)
|
||||
{
|
||||
if(stack_ck) {
|
||||
printf("Stack Check: Off\n") ;
|
||||
stack_ck = 0 ;
|
||||
} else {
|
||||
printf("Stack Check: On\n") ;
|
||||
stack_ck = 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
#define FILL_PATTERN 0xa596695a
|
||||
void stack_fill(char * stack, int size)
|
||||
{
|
||||
int i ;
|
||||
|
||||
if(stack_ck == 0)return ;
|
||||
for(i=1; i<size/4-10; i++)
|
||||
((int *)stack)[i] = FILL_PATTERN ;
|
||||
}
|
||||
|
||||
void stack_check(char * stack, int size)
|
||||
{
|
||||
int i ;
|
||||
|
||||
if(stack_ck == 0)return ;
|
||||
if(stack_ck == 1) {
|
||||
stack_ck ++ ; return ;
|
||||
}
|
||||
for(i=1; i<size/4 ; i++) {
|
||||
if(((int *)stack)[i] != FILL_PATTERN) break ;
|
||||
}
|
||||
if(i < size/4) {
|
||||
printf("Stack is used %d bytes out of %d\n", size - i*4, size) ;
|
||||
} else {
|
||||
printf("Stack overflow. Stack size: %d\n", size) ;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HAVE_KEIL_RTX */
|
||||
|
||||
static int for_iteration = 1 ;
|
||||
|
||||
static void for_command(void *args)
|
||||
{
|
||||
if( args == NULL || ((func_args *)args)->argc == 1) {
|
||||
printf("For %d times\n", for_iteration) ;
|
||||
} else if(((func_args *)args)->argc == 2) {
|
||||
for_iteration = atoi(((func_args *)args)->argv[1]) ;
|
||||
} else printf("Invalid argument\n") ;
|
||||
}
|
||||
|
||||
|
||||
#if defined(DEBUG_WOLFSSL)
|
||||
|
||||
static int wolfsslDebug = 1 ;
|
||||
|
||||
static void dbg_comm(void *args)
|
||||
{
|
||||
if(wolfsslDebug == 1) {
|
||||
wolfsslDebug = 0 ;
|
||||
printf("Turning OFF Debug message\n") ;
|
||||
wolfSSL_Debugging_OFF() ;
|
||||
} else {
|
||||
wolfsslDebug = 1 ;
|
||||
printf("Turning ON Debug message\n") ;
|
||||
wolfSSL_Debugging_ON() ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void help_comm(void *args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define BG_JOB_STACK_SIZE 16000
|
||||
#if (!defined(NO_SIMPLE_SERVER) && !defined(NO_ECHOSERVER)) && \
|
||||
defined(HAVE_KEIL_RTX)
|
||||
static char bg_job_stack[BG_JOB_STACK_SIZE] ;
|
||||
#endif
|
||||
|
||||
#define COMMAND_STACK_SIZE 16000
|
||||
#if defined(HAVE_KEIL_RTX)
|
||||
static char command_stack[COMMAND_STACK_SIZE] ;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
static wolfSSL_Mutex command_mutex ;
|
||||
#endif
|
||||
|
||||
/*********** Invoke Foreground Command *********************/
|
||||
static void command_invoke(void *args)
|
||||
{
|
||||
void (*func)(void * ) ;
|
||||
int i,iteration ;
|
||||
|
||||
func = (void(*)(void *))((func_args *)args)->argv[0] ;
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
wc_LockMutex((wolfSSL_Mutex *)&command_mutex) ;
|
||||
#endif
|
||||
iteration = for_iteration ;
|
||||
for(i=0; i< iteration; i++) {
|
||||
if(iteration > 1) printf("--- Start for %d ---->\n", i) ;
|
||||
#if defined(HAVE_KEIL_RTX)
|
||||
stack_fill(command_stack, COMMAND_STACK_SIZE) ;
|
||||
#endif
|
||||
|
||||
func(args) ; /* invoke command */
|
||||
|
||||
#if defined(HAVE_KEIL_RTX)
|
||||
stack_check(command_stack, COMMAND_STACK_SIZE) ;
|
||||
#endif
|
||||
}
|
||||
if(iteration > 1)
|
||||
for_iteration = 1 ;
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
|
||||
os_tsk_delete_self() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (!defined(NO_SIMPLE_SERVER) && !defined(NO_ECHOSERVER)) && \
|
||||
defined(HAVE_KEIL_RTX)
|
||||
/******* Invoke Background Job *******************************/
|
||||
static void bg_job_invoke(void *args)
|
||||
{
|
||||
void (*func)(void * ) ;
|
||||
BackGround = 1 ;
|
||||
stack_fill(bg_job_stack, BG_JOB_STACK_SIZE) ;
|
||||
func = (void(*)(void *))((func_args *)args)->argv[0] ;
|
||||
func(args) ; /* invoke command */
|
||||
stack_check(bg_job_stack, BG_JOB_STACK_SIZE) ;
|
||||
#ifdef WOLFSSL_KEIL_NET
|
||||
init_TcpNet ();
|
||||
#endif
|
||||
BackGround = 0 ;
|
||||
os_tsk_delete_self() ; ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define LINESIZE 100
|
||||
static char line[LINESIZE] ;
|
||||
|
||||
|
||||
/********* SHEULL MAIN LOOP ***********************************/
|
||||
void shell_main(void) {
|
||||
int i ;
|
||||
func_args args ;
|
||||
int bf_flg ;
|
||||
|
||||
i = BackGround ;
|
||||
/* Dummy for avoiding warning: BackGround is defined but not used. */
|
||||
|
||||
|
||||
#if defined(HAVE_KEIL_RTX)
|
||||
wc_InitMutex(&command_mutex) ;
|
||||
#endif
|
||||
printf("Starting Shell\n") ;
|
||||
while(1) {
|
||||
if(getline(line, LINESIZE, &args, &bf_flg) > 0) {
|
||||
for(i=0; commandTable[i].func != NULL; i++) {
|
||||
if(strcmp(commandTable[i].command, args.argv[0]) == 0) {
|
||||
args.argv[0] = (char *) commandTable[i].func ;
|
||||
if(bf_flg == FORGROUND) {
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
|
||||
os_tsk_create_user_ex( (void(*)(void *))&command_invoke, 7,
|
||||
command_stack, COMMAND_STACK_SIZE, &args) ;
|
||||
#else
|
||||
command_invoke(&args) ;
|
||||
#endif
|
||||
#ifdef HAVE_KEIL_RTX
|
||||
wc_LockMutex((wolfSSL_Mutex *)&command_mutex) ;
|
||||
#endif
|
||||
} else {
|
||||
#if (!defined(NO_SIMPLE_SERVER) && \
|
||||
!defined(NO_ECHOSERVER)) && \
|
||||
defined(HAVE_KEIL_RTX)
|
||||
if(BackGround != 0) {
|
||||
printf("Multiple background servers not supported.\n") ;
|
||||
} else {
|
||||
printf("\"%s\" is running with the background mode.\n",
|
||||
commandTable[i].command) ;
|
||||
os_tsk_create_user_ex( (void(*)(void *))&bg_job_invoke,
|
||||
6, bg_job_stack, BG_JOB_STACK_SIZE, &args) ;
|
||||
}
|
||||
#else
|
||||
printf("Invalid Command: no background job\n") ;
|
||||
#endif
|
||||
}
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if(commandTable[i].func == NULL)
|
||||
printf("Command not found\n") ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
42
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-CortexM3-4.c
vendored
Normal file
42
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-CortexM3-4.c
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/* time-STM32F2.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#define DWT ((DWT_Type *) (0xE0001000UL) )
|
||||
typedef struct
|
||||
{
|
||||
uint32_t CTRL; /*< Offset: 0x000 (R/W) Control Register */
|
||||
uint32_t CYCCNT; /*< Offset: 0x004 (R/W) Cycle Count Register */
|
||||
} DWT_Type;
|
||||
|
||||
extern uint32_t SystemCoreClock ;
|
||||
|
||||
double current_time(int reset)
|
||||
{
|
||||
if(reset) DWT->CYCCNT = 0 ;
|
||||
return ((double)DWT->CYCCNT/SystemCoreClock) ;
|
||||
}
|
||||
35
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-dummy.c
vendored
Normal file
35
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/time-dummy.c
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/* time-dummy.c.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "time.h"
|
||||
|
||||
struct tm *wolfssl_MDK_gmtime(const time_t *c)
|
||||
{
|
||||
static struct tm date ;
|
||||
return(&date) ;
|
||||
}
|
||||
|
||||
time_t time(time_t * t) { return 0 ; }
|
||||
247
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.c
vendored
Normal file
247
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.c
vendored
Normal file
@ -0,0 +1,247 @@
|
||||
/* wolfssl_KEIL_RL.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
/** This file is for defining functions for specific to KEIL-RL. **/
|
||||
/***************************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if defined(WOLFSSL_MDK_ARM)
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(WOLFSSL_MDK5)
|
||||
#include "cmsis_os.h"
|
||||
#include "rl_fs.h"
|
||||
#include "rl_net.h"
|
||||
#else
|
||||
#include "rtl.h"
|
||||
#endif
|
||||
|
||||
#include "wolfssl_MDK_ARM.h"
|
||||
#endif
|
||||
|
||||
#include "wolfssl_MDK_ARM.h"
|
||||
|
||||
#include <wolfssl/wolfcrypt/visibility.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
|
||||
#if defined (WOLFSSL_CMSIS_RTOS)
|
||||
#define os_dly_wait(t) osDelay(10*t)
|
||||
#endif
|
||||
|
||||
|
||||
/** KEIL-RL TCPnet ****/
|
||||
/** TCPnet BSD socket does not have following functions. **/
|
||||
|
||||
#if defined(WOLFSSL_KEIL_TCP_NET)
|
||||
char *inet_ntoa(struct in_addr in)
|
||||
{
|
||||
#define NAMESIZE 16
|
||||
static char name[NAMESIZE] ;
|
||||
sprintf(name, "%d.%d.%d.%d", (in.s_addr>>24)&0xff, (in.s_addr>>16)&0xff, (in.s_addr>>8)&0xff, in.s_addr&0xff) ;
|
||||
return name ;
|
||||
}
|
||||
|
||||
unsigned long inet_addr(const char *cp)
|
||||
{
|
||||
unsigned int a[4] ; unsigned long ret ;
|
||||
sscanf(cp, "%u.%u.%u.%u", &a[0], &a[1], &a[2], &a[3]) ;
|
||||
ret = ((a[3]<<24) + (a[2]<<16) + (a[1]<<8) + a[0]) ;
|
||||
return(ret) ;
|
||||
}
|
||||
|
||||
|
||||
/*** tcp_connect is actually associated with following syassl_tcp_connect. ***/
|
||||
int wolfssl_connect(int sd, const struct sockaddr* sa, int sz)
|
||||
{
|
||||
int ret = 0 ;
|
||||
#if defined(WOLFSSL_KEIL_TCP_NET)
|
||||
|
||||
SOCKADDR_IN addr ;
|
||||
|
||||
addr = *(SOCKADDR_IN *)sa ;
|
||||
|
||||
do {
|
||||
#undef connect /* Go to KEIL TCPnet connect */
|
||||
ret = connect(sd, (SOCKADDR *)&addr, sizeof(addr)) ;
|
||||
os_dly_wait(50);
|
||||
} while(ret == SCK_EWOULDBLOCK) ;
|
||||
#ifdef DEBUG_WOLFSSL
|
||||
{
|
||||
char msg[50] ;
|
||||
sprintf(msg, "BSD Connect return code: %d\n", ret) ;
|
||||
WOLFSSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_KEIL_TCP_NET */
|
||||
return(ret ) ;
|
||||
}
|
||||
|
||||
|
||||
int wolfssl_accept(int sd, struct sockaddr *addr, int *addrlen)
|
||||
{
|
||||
int ret = 0 ;
|
||||
|
||||
#if defined(WOLFSSL_KEIL_TCP_NET)
|
||||
while(1) {
|
||||
#undef accept /* Go to KEIL TCPnet accept */
|
||||
ret = accept(sd, addr, addrlen) ;
|
||||
if(ret != SCK_EWOULDBLOCK) break ;
|
||||
os_dly_wait(1);
|
||||
}
|
||||
#ifdef DEBUG_WOLFSSL
|
||||
{
|
||||
char msg[50] ;
|
||||
sprintf(msg, "BSD Accept return code: %d\n", ret) ;
|
||||
WOLFSSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_KEIL_TCP_NET */
|
||||
return(ret ) ;
|
||||
|
||||
}
|
||||
|
||||
int wolfssl_recv(int sd, void *buf, size_t len, int flags)
|
||||
{
|
||||
int ret = 0;
|
||||
#if defined(WOLFSSL_KEIL_TCP_NET)
|
||||
while(1) {
|
||||
#undef recv /* Go to KEIL TCPnet recv */
|
||||
ret = recv(sd, buf, len, flags) ;
|
||||
if((ret != SCK_EWOULDBLOCK) &&( ret != SCK_ETIMEOUT)) break ;
|
||||
os_dly_wait(1);
|
||||
}
|
||||
#ifdef DEBUG_WOLFSSL
|
||||
{
|
||||
char msg[50] ;
|
||||
sprintf(msg, "BSD Recv return code: %d\n", ret) ;
|
||||
WOLFSSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_KEIL_TCP_NET */
|
||||
return(ret ) ;
|
||||
}
|
||||
|
||||
int wolfssl_send(int sd, const void *buf, size_t len, int flags)
|
||||
{
|
||||
int ret = 0 ;
|
||||
|
||||
#if defined(WOLFSSL_KEIL_TCP_NET)
|
||||
while(1) {
|
||||
#undef send /* Go to KEIL TCPnet send */
|
||||
ret = send(sd, buf, len, flags) ;
|
||||
if(ret != SCK_EWOULDBLOCK) break ;
|
||||
os_dly_wait(1);
|
||||
}
|
||||
#ifdef DEBUG_WOLFSSL
|
||||
{
|
||||
char msg[50] ;
|
||||
sprintf(msg, "BSD Send return code: %d\n", ret) ;
|
||||
WOLFSSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_KEIL_TCP_NET */
|
||||
return(ret) ;
|
||||
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_KEIL_TCP_NET */
|
||||
|
||||
#if defined(WOLFSSL_KEIL_TCP_NET)
|
||||
void wolfssl_sleep(int t)
|
||||
{
|
||||
#if defined(HAVE_KEIL_RTX)
|
||||
os_dly_wait(t/1000+1) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
int wolfssl_tcp_select(int sd, int timeout)
|
||||
{
|
||||
|
||||
return 0 ;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
FILE * wolfSSL_fopen(const char *name, const char *openmode)
|
||||
{
|
||||
int i ; FILE * ret ;
|
||||
#define PATHSIZE 100
|
||||
char path[PATHSIZE] ; char *p ;
|
||||
|
||||
if(strlen(name) > PATHSIZE)return(NULL) ;
|
||||
|
||||
for(i = 0; i<= strlen(name); i++) {
|
||||
if(name[i] == '/')path[i] = '\\' ;
|
||||
else path[i] = name[i] ;
|
||||
}
|
||||
if(path[0] == '.' && path[1] == '\\') p = path + 2 ;
|
||||
else p = path ;
|
||||
|
||||
ret = fopen (p, openmode) ;
|
||||
|
||||
return(ret) ;
|
||||
}
|
||||
|
||||
#define getkey getchar
|
||||
#define sendchar putchar
|
||||
|
||||
char * wolfssl_fgets ( char * str, int num, FILE * f )
|
||||
{
|
||||
int i ;
|
||||
|
||||
for(i = 0 ; i< num ; i++) {
|
||||
while((str[i] = getkey()) == 0) {
|
||||
#if defined (HAVE_KEIL_RTX) && !defined(WOLFSSL_CMSIS_RTOS)
|
||||
os_tsk_pass ();
|
||||
#elif defined(WOLFSSL_CMSIS_RTOS)
|
||||
osThreadYield ();
|
||||
#endif
|
||||
}
|
||||
if(str[i] == '\n' || str[i] == '\012' || str[i] == '\015') {
|
||||
sendchar('\n') ;
|
||||
str[i++] = '\n' ;
|
||||
str[i] = '\0' ;
|
||||
break ;
|
||||
} else if(str[i] == '\010') { /* BS */
|
||||
if(i) { /* erace one char */
|
||||
sendchar('\010') ; sendchar(' ') ; sendchar('\010') ;
|
||||
i = (i>0 ? (i-2) : -1 ) ;
|
||||
continue ;
|
||||
}
|
||||
} else if(str[i] == '\033' || str[i] == '\004' ) { /* ESC or ^D */
|
||||
str[i] = '\0' ;
|
||||
return(0) ;
|
||||
}
|
||||
sendchar(str[i]) ;
|
||||
}
|
||||
return(str) ;
|
||||
}
|
||||
99
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.h
vendored
Normal file
99
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/MDK-ARM/wolfSSL/wolfssl_MDK_ARM.h
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
/* wolfssl_KEIL_RL.h
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/** This file is for defining types, values for specific to KEIL-MDK-ARM. **/
|
||||
/******************************************************************************/
|
||||
#ifndef WOLFSSL_KEIL_RL_H
|
||||
#define WOLFSSL_KEIL_RL_H
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Go to STDIN */
|
||||
#define fgets(buff, sz, fd) wolfssl_fgets(buff, sz, fd)
|
||||
extern char * wolfssl_fgets ( char * str, int num, FILE * f ) ;
|
||||
|
||||
#define SOCKET_T int
|
||||
|
||||
/*** #include <socket.h> ***/
|
||||
#define NUMBITSPERBYTE 8
|
||||
#define FD_SETSIZE 10
|
||||
|
||||
typedef long fd_mask;
|
||||
#define NFDBITS (sizeof(fd_mask) * NUMBITSPERBYTE) /* bits per mask */
|
||||
|
||||
typedef struct fd_set {
|
||||
fd_mask fds_bits[(FD_SETSIZE + NFDBITS - 1) / NFDBITS];
|
||||
} fd_set;
|
||||
|
||||
/*** #include <sys/types.h> ***/
|
||||
struct timeval {
|
||||
long tv_sec; /* seconds */
|
||||
long tv_usec; /* microseconds */
|
||||
};
|
||||
|
||||
#if defined(WOLFSSL_KEIL_TCP_NET)
|
||||
|
||||
#if defined(WOLFSSL_MDK5)
|
||||
#define SCK_EWOULDBLOCK BSD_ERROR_WOULDBLOCK
|
||||
#define SCK_ETIMEOUT BSD_ERROR_TIMEOUT
|
||||
#include "rl_net.h"
|
||||
#endif
|
||||
|
||||
typedef int socklen_t ;
|
||||
|
||||
/* for avoiding conflict with KEIL-TCPnet BSD socket */
|
||||
/* Bodies are in wolfssl_KEIL_RL.c */
|
||||
#define connect(a,b,c) wolfssl_connect(a, (struct sockaddr* )(b), c)
|
||||
#define accept wolfssl_accept
|
||||
#define recv wolfssl_recv
|
||||
#define send wolfssl_send
|
||||
#define sleep wolfssl_sleep
|
||||
|
||||
/* for avoiding conflicting with KEIL-TCPnet TCP socket */
|
||||
/* Bodies are in test.h */
|
||||
#define tcp_connect wolfssl_tcp_connect
|
||||
#define tcp_socket wolfssl_tcp_soket
|
||||
#define tcp_listen wolfssl_tcp_listen
|
||||
#define tcp_select wolfssl_tcp_select
|
||||
|
||||
extern int wolfssl_connect(int sd, const struct sockaddr* sa, int sz) ;
|
||||
extern int wolfssl_accept(int sd, struct sockaddr*addr, socklen_t *addrlen);
|
||||
extern int wolfssl_recv(int sd, void *buf, size_t len, int flags);
|
||||
extern int wolfssl_send(int sd, const void *buf, size_t len, int flags);
|
||||
extern void wolfssl_sleep(int sec) ;
|
||||
extern int wolfssl_tcp_select(int sd, int timeout) ;
|
||||
|
||||
/** KEIL-RL TCPnet ****/
|
||||
/* TCPnet BSD socket does not have following functions. */
|
||||
extern char *inet_ntoa(struct in_addr in);
|
||||
extern unsigned long inet_addr(const char *cp);
|
||||
extern int setsockopt(int sockfd, int level, int optname,
|
||||
const void *optval, socklen_t optlen);
|
||||
extern int select(int nfds, fd_set *readfds, fd_set *writefds,
|
||||
fd_set *exceptfds, const struct timeval *timeout);
|
||||
|
||||
#endif /* WOLFSSL_KEIL_TCP_NET */
|
||||
|
||||
#endif /* WOLFSSL_KEIL_RL_H */
|
||||
300
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/STM32F2xx_StdPeriph_Lib/time-STM32F2xx.c
vendored
Normal file
300
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/MDK-ARM/STM32F2xx_StdPeriph_Lib/time-STM32F2xx.c
vendored
Normal file
@ -0,0 +1,300 @@
|
||||
/* time-STM32F2xx.c
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "time.h"
|
||||
|
||||
#define PERIPH_BASE ((uint32_t)0x40000000)
|
||||
/*-----------------------------------------------------------------------------
|
||||
* initialize RTC
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "stm32f2xx.h"
|
||||
|
||||
#define assert_param(a)
|
||||
|
||||
#define RTC_RSF_MASK ((uint32_t)0xFFFFFF5F)
|
||||
#define SYNCHRO_TIMEOUT ((uint32_t) 0x00008000)
|
||||
#define Bcd2ToByte(v) \
|
||||
((((uint8_t)(v & (uint8_t)0xF0) >> (uint8_t)0x4) * 10) + (v & (uint8_t)0x0F))
|
||||
#define RTC_TR_RESERVED_MASK ((uint32_t)0x007F7F7F)
|
||||
#define RTC_TR_MNT ((uint32_t)0x00007000)
|
||||
#define RTC_TR_MNU ((uint32_t)0x00000F00)
|
||||
|
||||
#define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
|
||||
#define CR_OFFSET (PWR_OFFSET + 0x00)
|
||||
#define DBP_BitNumber 0x08
|
||||
#define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4))
|
||||
#define RTC_INIT_MASK ((uint32_t)0xFFFFFFFF)
|
||||
#define INITMODE_TIMEOUT ((uint32_t) 0x00010000)
|
||||
|
||||
static void init_RTC()
|
||||
{
|
||||
__IO uint32_t initcounter = 0x00 ;
|
||||
uint32_t initstatus = 0x00; /* Enable the PWR clock : RCC_APB1Periph_PWR */
|
||||
((uint32_t *)RCC)[0x10] |= ((uint32_t)0x10000000) ;
|
||||
|
||||
/* Allow access to RTC */
|
||||
*(__IO uint32_t *) CR_DBP_BB = ENABLE ;
|
||||
/* RCC_LSEConfig(RCC_LSE_ON) */
|
||||
*(__IO uint8_t *) (RCC_BASE + 0x70) = ((uint8_t)0x00);
|
||||
/* Reset LSEBYP bit */
|
||||
*(__IO uint8_t *) (RCC_BASE + 0x70) = ((uint8_t)0x00);
|
||||
*(__IO uint8_t *) (RCC_BASE + 0x70) = ((uint8_t)0x01);
|
||||
/* Wait till LSE is ready */
|
||||
while((RCC->BDCR << 0x2) == 0x0) { }
|
||||
/* Select the RTC clock source: RCC_RTCCLKSource_LSE */
|
||||
((RCC_TypeDef *)RCC)->BDCR |= (uint32_t)0x00000100;
|
||||
|
||||
/* Enable the RTC Clock */
|
||||
*(__IO uint32_t *) (PERIPH_BB_BASE + (((RCC_BASE - PERIPH_BASE)+ 0x70) * 32) + (0x0F* 4)) = (uint32_t)ENABLE;
|
||||
|
||||
*(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE;
|
||||
RTC->ISR = (uint32_t) RTC_INIT_MASK;
|
||||
do {
|
||||
initstatus = RTC->ISR & RTC_ISR_INITF;
|
||||
initcounter++;
|
||||
} while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00));
|
||||
|
||||
/* Disable the write protection for RTC registers */
|
||||
RTC->WPR = 0xCA;
|
||||
RTC->WPR = 0x53;
|
||||
|
||||
RTC->CR &= ((uint32_t)~(RTC_CR_FMT)); /* Clear RTC CR FMT Bit */
|
||||
/* Set RTC_CR register */
|
||||
RTC->CR |= ((uint32_t)0x00000000) ; /* RTC_HourFormat_24 */
|
||||
|
||||
/* Configure the RTC PRER */
|
||||
RTC->PRER = 0x7f ;
|
||||
RTC->PRER |= (uint32_t)(0xff << 16);
|
||||
|
||||
/* Exit Initialization mode */
|
||||
RTC->ISR &= (uint32_t)~RTC_ISR_INIT;
|
||||
|
||||
/* Enable the write protection for RTC registers */
|
||||
RTC->WPR = 0xFF;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* initialize TIM
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define RCC_APB1Periph_TIM2 ((uint32_t)0x00000001)
|
||||
|
||||
static void init_TIM()
|
||||
{
|
||||
uint16_t tmpcr1 = 0;
|
||||
|
||||
((uint32_t *)RCC)[0x10] |= RCC_APB1Periph_TIM2 ;
|
||||
|
||||
tmpcr1 = TIM2->CR1 ;
|
||||
tmpcr1 &= (uint16_t) (~(((uint16_t)0x0010) | ((uint16_t)0x0060) ));
|
||||
/* CR1 &= ~(TIM_CR1_DIR | TIM_CR1_CMS) */
|
||||
tmpcr1 |= (uint16_t)0x0000 ; /* CR1 |= TIM_CounterMode_Up */
|
||||
TIM2->CR1= tmpcr1 ;
|
||||
|
||||
TIM2->ARR = 0xffffffff ; /* ARR= TIM_Period */
|
||||
TIM2->PSC = 60 ; /* PSC = TIM_Prescaler */
|
||||
TIM2->EGR = ((uint16_t)0x0001) ; /* EGR = TIM_PSCReloadMode_Immediate */
|
||||
|
||||
*(uint16_t *)(PERIPH_BASE+0x0) |=((uint16_t)0x0001) ;
|
||||
/* TIM_Cmd(TIM2, ENABLE) ; */
|
||||
}
|
||||
|
||||
void init_time(void) {
|
||||
init_RTC() ;
|
||||
init_TIM() ;
|
||||
}
|
||||
|
||||
static void GetTime(uint8_t *h, uint8_t *m, uint8_t *s)
|
||||
{
|
||||
uint32_t tmpreg = 0;
|
||||
tmpreg = (uint32_t)(RTC->TR & RTC_TR_RESERVED_MASK);
|
||||
*h = (uint8_t)Bcd2ToByte((uint8_t)((tmpreg & (RTC_TR_HT | RTC_TR_HU)) >> 16));
|
||||
*m = (uint8_t)Bcd2ToByte((uint8_t)((tmpreg & (RTC_TR_MNT | RTC_TR_MNU)) >>8));
|
||||
*s = (uint8_t)Bcd2ToByte((tmpreg & (RTC_TR_ST | RTC_TR_SU)));
|
||||
}
|
||||
|
||||
static uint32_t ByteToBcd2(uint8_t Value)
|
||||
{
|
||||
uint8_t bcdhigh = 0;
|
||||
while (Value >= 10) {
|
||||
bcdhigh++;
|
||||
Value -= 10;
|
||||
}
|
||||
return ((uint8_t)(bcdhigh << 4) | Value);
|
||||
}
|
||||
|
||||
static void SetTime(uint8_t h, uint8_t m, uint8_t s)
|
||||
{
|
||||
__IO uint32_t synchrocounter = 0;
|
||||
uint32_t synchrostatus = 0x00;
|
||||
__IO uint32_t initcounter = 0;
|
||||
uint32_t initstatus = 0x00;
|
||||
uint32_t tmpreg ;
|
||||
|
||||
tmpreg = ((ByteToBcd2(h) << 16) | (ByteToBcd2(m) << 8) | ByteToBcd2(s)) ;
|
||||
/* Disable the write protection for RTC registers */
|
||||
RTC->WPR = 0xCA;
|
||||
RTC->WPR = 0x53;
|
||||
RTC->ISR &= (uint32_t)~RTC_ISR_INIT;
|
||||
|
||||
RTC->ISR = (uint32_t)RTC_INIT_MASK;
|
||||
|
||||
/* Wait till RTC is in INIT state and if Time out is reached exit */
|
||||
do {
|
||||
initstatus = RTC->ISR & RTC_ISR_INITF;
|
||||
initcounter++;
|
||||
} while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00));
|
||||
|
||||
RTC->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
|
||||
|
||||
RTC->ISR &= (uint32_t)RTC_RSF_MASK;
|
||||
/* Wait the registers to be synchronised */
|
||||
do {
|
||||
synchrostatus = RTC->ISR & RTC_ISR_RSF;
|
||||
synchrocounter++;
|
||||
} while((synchrocounter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));
|
||||
|
||||
RTC->WPR = 0xFF;
|
||||
}
|
||||
|
||||
static void GetDate(uint8_t *y, uint8_t *m, uint8_t *d)
|
||||
{
|
||||
uint32_t tmpreg = 0;
|
||||
tmpreg = (uint32_t)(RTC->DR & RTC_TR_RESERVED_MASK);
|
||||
*y = (uint8_t)Bcd2ToByte((uint8_t)((tmpreg & (RTC_DR_YT|RTC_DR_YU)) >>16));
|
||||
*m = (uint8_t)Bcd2ToByte((uint8_t)((tmpreg & (RTC_DR_MT|RTC_DR_MU)) >> 8));
|
||||
*d = (uint8_t)Bcd2ToByte((uint8_t)(tmpreg & (RTC_DR_DT |RTC_DR_DU)));
|
||||
}
|
||||
|
||||
static void SetDate(uint8_t y, uint8_t m, uint8_t d)
|
||||
{
|
||||
__IO uint32_t synchrocounter = 0;
|
||||
uint32_t synchrostatus = 0x00;
|
||||
__IO uint32_t initcounter = 0;
|
||||
uint32_t initstatus = 0x00;
|
||||
uint32_t tmpreg = 0 ;
|
||||
|
||||
tmpreg = ((ByteToBcd2(y) << 16) | (ByteToBcd2(m) << 8) | ByteToBcd2(d)) ;
|
||||
/* Disable the write protection for RTC registers */
|
||||
RTC->WPR = 0xCA;
|
||||
RTC->WPR = 0x53;
|
||||
RTC->ISR &= (uint32_t)~RTC_ISR_INIT;
|
||||
|
||||
RTC->ISR = (uint32_t)RTC_INIT_MASK;
|
||||
|
||||
/* Wait till RTC is in INIT state and if Time out is reached exit */
|
||||
do {
|
||||
initstatus = RTC->ISR & RTC_ISR_INITF;
|
||||
initcounter++;
|
||||
} while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00));
|
||||
|
||||
RTC->DR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
|
||||
|
||||
RTC->ISR &= (uint32_t)RTC_RSF_MASK;
|
||||
/* Wait the registers to be synchronised */
|
||||
do {
|
||||
synchrostatus = RTC->ISR & RTC_ISR_RSF;
|
||||
synchrocounter++;
|
||||
} while((synchrocounter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));
|
||||
|
||||
RTC->WPR = 0xFF;
|
||||
}
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
void CYASSL_MSG(const char *msg) ;
|
||||
|
||||
struct tm *Cyassl_MDK_gmtime(const time_t *c)
|
||||
{
|
||||
uint8_t h, m, s ;
|
||||
uint8_t y, mo, d ;
|
||||
static struct tm date ;
|
||||
|
||||
GetTime(&h, &m, &s) ;
|
||||
GetDate(&y, &mo, &d) ;
|
||||
|
||||
date.tm_year = y + 100 ;
|
||||
date.tm_mon = mo - 1 ;
|
||||
date.tm_mday = d ;
|
||||
date.tm_hour = h ;
|
||||
date.tm_min = m ;
|
||||
date.tm_sec = s ;
|
||||
|
||||
#if defined(DEBUG_CYASSL)
|
||||
{
|
||||
char msg[100] ;
|
||||
sprintf(msg,
|
||||
"Debug::Cyassl_KEIL_gmtime(DATE=/%2d/%02d/%04d TIME=%02d:%02d:%02d)\n",
|
||||
d, mo, y+2000, h, m, s) ;
|
||||
CYASSL_MSG(msg) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
return(&date) ;
|
||||
}
|
||||
|
||||
double current_time()
|
||||
{
|
||||
return ((double)TIM2->CNT/1000000.0) ;
|
||||
}
|
||||
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
void time_main(void *args)
|
||||
{
|
||||
char * datetime ;
|
||||
uint8_t h, m, s ;
|
||||
uint8_t y, mo, d ;
|
||||
|
||||
if( args == NULL || ((func_args *)args)->argc == 1) {
|
||||
GetTime(&h, &m, &s) ;
|
||||
GetDate(&y, &mo, &d) ;
|
||||
printf("Date: %d/%d/%d, Time: %02d:%02d:%02d\n",
|
||||
mo, d, y+2000, h, m, s) ;
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-' &&
|
||||
((func_args *)args)->argv[1][1] == 'd' ) {
|
||||
datetime = ((func_args *)args)->argv[2];
|
||||
sscanf(datetime, "%d/%d/%d", (int *)&mo, (int *)&d, (int *) &y) ;
|
||||
SetDate(y-2000, mo, d) ;
|
||||
} else if(((func_args *)args)->argc == 3 &&
|
||||
((func_args *)args)->argv[1][0] == '-' &&
|
||||
((func_args *)args)->argv[1][1] == 't' ) {
|
||||
datetime = ((func_args *)args)->argv[2];
|
||||
sscanf(datetime, "%d:%d:%d",
|
||||
(int *)&h, (int *)&m, (int *)&s) ;
|
||||
SetTime(h, m, s) ;
|
||||
} else printf("Invalid argument\n") ;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
time()
|
||||
********************************************************************/
|
||||
time_t time(time_t * t) { return 0 ; }
|
||||
Reference in New Issue
Block a user